Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter benw91

    (@benw91)

    I added this code to generate the attachment_metadata array while making sure that the serialization is correct:

    		//Get function which checks whether serialization was correct
    		if(!function_exists("serialize_corrector")) {
    			function serialize_corrector($serialized_string){
    			// at first, check if "fixing" is really needed at all. After that, security checkup.
    				if ( @unserialize($serialized_string) !== true &&  preg_match('/^[aOs]:/', $serialized_string) ) {
    					$serialized_string = preg_replace_callback( '/s\:(\d+)\:\"(.*?)\";/s',    function($matches){return 's:'.strlen($matches[2]).':"'.$matches[2].'";'; },   $serialized_string );
    				}
    				return $serialized_string;
    			};
    		}
    		// Get the images in the attachement table
    		$all_images = $wpdb->get_results($queryUnoptimizedPicture);
    		
    		foreach($all_images as $image){
    			$tmp = array();
    			$tmp['ID'] = $image->ID;
    			
    			if (isset($image->file_meta)) {
    				$tmp_serialized_file_meta = serialize_corrector($image->file_meta);
    				$tmp['attachment_metadata'] = unserialize($tmp_serialized_file_meta);
    			}
    			else {
    				$tmp['attachment_metadata'] = array();
    			}

    Now I’m getting the following warning in the log when I try to optimize an image:
    PHP Warning: file_get_contents(https://par2.static.resmush.it/<path&gt;.png): failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable
    in <path>/plugins/resmushit-image-optimizer/classes/resmushit.class.php on line 92
    On the UI no error is shown, it’s just shown as processing and nothing happens

Viewing 1 replies (of 1 total)