在我的Apache ErrorLog
文件中,我多次看到此警告消息:
[Wed Aug 23 17:27:25.146025 2017] [:error] [pid 14989] [client 66.249.76.54:44935] PHP警告:isset中的非法偏移类型或/ var / www / html / blog /中为空第1012行的wp-content / plugins / ilab-media-tools / classes / tools / s3 / ilab-media-s3-tool.php
它与Wordpress插件相关,我尝试Github向作者(许多其他人)寻求帮助,但没有。
警告指向此功能:
public function imageDownsize($fail,$id,$size) {
if (apply_filters('ilab_imgix_enabled', false)) {
return $fail;
}
$meta=wp_get_attachment_metadata($id);
// This is the line of the warning:
if (!isset($meta['sizes']) || !isset($meta['sizes'][$size])) {
return $fail;
}
$sizeMeta = $meta['sizes'][$size];
if (!isset($sizeMeta['s3'])) {
return $fail;
}
$url = $sizeMeta['s3']['url'];
$result=[
$url,
$sizeMeta['width'],
$sizeMeta['height'],
true
];
return $result;
}
Apache每分钟打印一次此警告。 有没有办法解决这个恼人的消息警告?
这是var_dump($meta);
:
array(7) {
["width"]=>
int(140)
["height"]=>
int(140)
["file"]=>
string(31) "2016/01/logo_retina.png"
["sizes"]=>
array(0) {
}
["image_meta"]=>
array(12) {
["aperture"]=>
int(0)
["credit"]=>
string(0) ""
["camera"]=>
string(0) ""
["caption"]=>
string(0) ""
["created_timestamp"]=>
int(0)
["copyright"]=>
string(0) ""
["focal_length"]=>
int(0)
["iso"]=>
int(0)
["shutter_speed"]=>
int(0)
["title"]=>
string(0) ""
["orientation"]=>
int(0)
["keywords"]=>
array(0) {
}
}
["ewww_image_optimizer"]=>
string(30) "Reduced by 16.3% (1.3 kB)"
["s3"]=>
array(3) {
["url"]=>
string(79) "https://s3-eu-west-1.amazonaws.com/blog-example/2016/01/logo_retina.png"
["bucket"]=>
string(12) "blog-example"
["key"]=>
string(31) "2016/01/logo_retina.png"
}
}
array(7) {
["width"]=>
int(140)
["height"]=>
int(140)
["file"]=>
string(31) "2016/01/logo_retina.png"
["sizes"]=>
array(0) {
}
["image_meta"]=>
array(12) {
["aperture"]=>
int(0)
["credit"]=>
string(0) ""
["camera"]=>
string(0) ""
["caption"]=>
string(0) ""
["created_timestamp"]=>
int(0)
["copyright"]=>
string(0) ""
["focal_length"]=>
int(0)
["iso"]=>
int(0)
["shutter_speed"]=>
int(0)
["title"]=>
string(0) ""
["orientation"]=>
int(0)
["keywords"]=>
array(0) {
}
}
["ewww_image_optimizer"]=>
string(30) "Reduced by 16.3% (1.3 kB)"
["s3"]=>
array(3) {
["url"]=>
string(79) "https://s3-eu-west-1.amazonaws.com/blog-example/2016/01/logo_retina.png"
["bucket"]=>
string(12) "blog-example"
["key"]=>
string(31) "2016/01/logo_retina.png"
}
}
array(7) {
["width"]=>
int(140)
["height"]=>
int(140)
["file"]=>
string(31) "2016/01/logo_retina.png"
["sizes"]=>
array(0) {
}
["image_meta"]=>
array(12) {
["aperture"]=>
int(0)
["credit"]=>
string(0) ""
["camera"]=>
string(0) ""
["caption"]=>
string(0) ""
["created_timestamp"]=>
int(0)
["copyright"]=>
string(0) ""
["focal_length"]=>
int(0)
["iso"]=>
int(0)
["shutter_speed"]=>
int(0)
["title"]=>
string(0) ""
["orientation"]=>
int(0)
["keywords"]=>
array(0) {
}
}
["ewww_image_optimizer"]=>
string(30) "Reduced by 16.3% (1.3 kB)"
["s3"]=>
array(3) {
["url"]=>
string(79) "https://s3-eu-west-1.amazonaws.com/blog-example/2016/01/logo_retina.png"
["bucket"]=>
string(12) "blog-example"
["key"]=>
string(31) "2016/01/logo_retina.png"
}
}
array(7) {
["width"]=>
int(140)
["height"]=>
int(140)
["file"]=>
string(31) "2016/01/logo_retina.png"
["sizes"]=>
array(0) {
}
["image_meta"]=>
array(12) {
["aperture"]=>
int(0)
["credit"]=>
string(0) ""
["camera"]=>
string(0) ""
["caption"]=>
string(0) ""
["created_timestamp"]=>
int(0)
["copyright"]=>
string(0) ""
["focal_length"]=>
int(0)
["iso"]=>
int(0)
["shutter_speed"]=>
int(0)
["title"]=>
string(0) ""
["orientation"]=>
int(0)
["keywords"]=>
array(0) {
}
}
["ewww_image_optimizer"]=>
string(30) "Reduced by 16.3% (1.3 kB)"
["s3"]=>
array(3) {
["url"]=>
string(79) "https://s3-eu-west-1.amazonaws.com/blog-example/2016/01/logo_retina.png"
["bucket"]=>
string(12) "blog-example"
["key"]=>
string(31) "2016/01/logo_retina.png"
}
}
array(7) {
["width"]=>
int(140)
["height"]=>
int(140)
["file"]=>
string(31) "2016/01/logo_retina.png"
["sizes"]=>
array(0) {
}
["image_meta"]=>
array(12) {
["aperture"]=>
int(0)
["credit"]=>
string(0) ""
["camera"]=>
string(0) ""
["caption"]=>
string(0) ""
["created_timestamp"]=>
int(0)
["copyright"]=>
string(0) ""
["focal_length"]=>
int(0)
["iso"]=>
int(0)
["shutter_speed"]=>
int(0)
["title"]=>
string(0) ""
["orientation"]=>
int(0)
["keywords"]=>
array(0) {
}
}
["ewww_image_optimizer"]=>
string(30) "Reduced by 16.3% (1.3 kB)"
["s3"]=>
array(3) {
["url"]=>
string(79) "https://s3-eu-west-1.amazonaws.com/blog-example/2016/01/logo_retina.png"
["bucket"]=>
string(12) "blog-example"
["key"]=>
string(31) "2016/01/logo_retina.png"
}
}
var_dump($size);
的输出:
string(4) "full"
array(2) {
[0]=>
int(32)
[1]=>
int(32)
}
array(2) {
[0]=>
int(192)
[1]=>
int(192)
}
array(2) {
[0]=>
int(180)
[1]=>
int(180)
}
array(2) {
[0]=>
int(270)
[1]=>
int(270)
}
答案 0 :(得分:0)
因此,基于GitHub问题,看起来这条线路以某种方式失败
var arOptions = {"1","2","3"};
var strLine = String.Join(arOptions,'|');
根据WP reference返回
附件元字段。失败时是假的。
代码错误地假设它总是会得到一个数组。因此,您可以通过更改以下内容来解决此问题,以确保$meta=wp_get_attachment_metadata($id);
不是
$meta