Magic-Fields-2 icon indicating copy to clipboard operation
Magic-Fields-2 copied to clipboard

Recoverable fatal error

Open kleinermann opened this issue 7 years ago • 4 comments

I get the following fatal error (see below after the warnings):

Warning: Illegal string offset 'original' in /Applications/MAMP/htdocs/bussenstueble.de/wordpress/wp-content/plugins/magic-fields-2/mf_front_end.php on line 523

Warning: Illegal string offset 'original' in /Applications/MAMP/htdocs/bussenstueble.de/wordpress/wp-content/plugins/magic-fields-2/mf_front_end.php on line 527

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; mfthumb has a deprecated constructor in /Applications/MAMP/htdocs/bussenstueble.de/wordpress/wp-content/plugins/magic-fields-2/MF_thumb.php on line 12

Warning: Illegal string offset 'thumb' in /Applications/MAMP/htdocs/bussenstueble.de/wordpress/wp-content/plugins/magic-fields-2/mf_front_end.php on line 527

Recoverable fatal error: Object of class WP_Error could not be converted to string in /Applications/MAMP/htdocs/bussenstueble.de/wordpress/wp-content/plugins/magic-fields-2/mf_front_end.php on line 527

This only happens on my local test environment.

I have checked in mf_front_end.php. This is the code from line 523:

$result['original'] = $data[0];
 if( empty($options) ){
   $result['thumb'] = $result['original'];
}else{
   $result['thumb'] = aux_image($result['original'],$options,$type);
   if ( is_wp_error($result['thumb']) ){
      $result['error'] = $result['thumb']->get_error_message();
      $result['thumb'] = '';
    }
}

I've checked the $result variable and found that it contains an empty string, which causes the script to throw an error. I don't understand why the $result variable could be empty. I'd be very grateful for any tip.

kleinermann avatar Oct 10 '17 13:10 kleinermann

I have exactly the same problem. Could someone from the dev team help please?

s-patompong avatar Mar 18 '19 11:03 s-patompong

I have exactly the same problem. Could someone from the dev team help please?

need to set type for $result to array:

$result = array();

      $result = array(); //fix
      $data = wp_get_attachment_image_src($value,'original');
      $result['original'] = $data[0];
      if( empty($options) ){
        $result['thumb'] = $result['original'];
      }else{
        $result['thumb'] = aux_image($result['original'],$options,$type);
        if ( is_wp_error($result['thumb']) ){
          $result['error'] = $result['thumb']->get_error_message();
          $result['thumb'] = '';
        }
      }

stasdk3000 avatar Apr 18 '19 07:04 stasdk3000

Better replace $result = ''; with $result = array(); in line 448 this solves the problem for all media types.

BMo-design avatar May 18 '19 16:05 BMo-design

I have same issue, @BMo-design Solution works.

grigorii-horos avatar Jul 08 '19 12:07 grigorii-horos