Support » Plugin: WordPress Importer » Notice: wp_get_http is deprecated since version 4.4!

Viewing 15 replies - 1 through 15 (of 21 total)
  • same notice here!

    Hi @webcodebuilder , @dmsr
    I have a solution , you can open file plugins/wordpress-importer/wordpress-importer.php
    and replace function fetch_remote_file by

    function fetch_remote_file( $url, $post ) {
    		// extract the file name and extension from the url
    		$file_name = basename( $url );
    
    		// get placeholder file in the upload dir with a unique, sanitized filename
    		$upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
    		if ( $upload['error'] )
    			return new WP_Error( 'upload_dir_error', $upload['error'] );
    
    		// fetch the remote url and write it to the placeholder file
    		$response = wp_remote_get( $url, array(
    			'stream' => true,
    			'filename' => $upload['file']
    		) );
    
    		// request failed
    		if ( is_wp_error( $response ) ) {
    			@unlink( $upload['file'] );
    			return $response;
    		}
    
    		$code = (int) wp_remote_retrieve_response_code( $response );
    
    		// make sure the fetch was successful
    		if ( $code !== 200 ) {
    			@unlink( $upload['file'] );
    			return new WP_Error(
    				'import_file_error',
    				sprintf(
    					__('Remote server returned %1$d %2$s for %3$s', 'wordpress-importer'),
    					$code,
    					get_status_header_desc( $code ),
    					$url
    				)
    			);
    		}
    
    		$filesize = filesize( $upload['file'] );
    		$headers = wp_remote_retrieve_headers( $response );
    
    		if ( isset( $headers['content-length'] ) && $filesize != $headers['content-length'] ) {
    			@unlink( $upload['file'] );
    			return new WP_Error( 'import_file_error', __('Remote file is incorrect size', 'wordpress-importer') );
    		}
    
    		if ( 0 == $filesize ) {
    			@unlink( $upload['file'] );
    			return new WP_Error( 'import_file_error', __('Zero size file downloaded', 'wordpress-importer') );
    		}
    
    		$max_size = (int) $this->max_attachment_size();
    		if ( ! empty( $max_size ) && $filesize > $max_size ) {
    			@unlink( $upload['file'] );
    			return new WP_Error( 'import_file_error', sprintf(__('Remote file is too large, limit is %s', 'wordpress-importer'), size_format($max_size) ) );
    		}
    
    		// keep track of the old and new urls so we can substitute them later
            $this->url_remap[$url] = $upload['url'];
            $this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed?
            // keep track of the destination if the remote url is redirected somewhere else
            if ( isset($headers['x-final-location']) && $headers['x-final-location'] != $url ){
            	$this->url_remap[$headers['x-final-location']] = $upload['url'];
    		}
    
    		return $upload;
    	}

    hope to help you

    Thread Starter Webcodebuilder

    (@webcodebuilder)

    Well this solution will work only if it’s you who install the plugin or do the import. But if it’s your customer it’s not very good when you give them such an instruction))

    Of course, @wordpress.org please update this plugin compatible with WP 4.4 !

    The complete fixed file wordpress-importer.php can be downloaded here.

    http://pastebin.com/14xJER5S

    It is php7 compatible and working on wp 4.4

    It also has fixes from other threads. You can do a compare using winmerge. 🙂

    including choijuns code fix

    Replace the content of that file with the content at pastebin

    I noticed some failure on the import of content due to this new function….

    Maybe it is not 100% save.

    The old function is also still in the code and can be (re)activated.

    The provided solution definitly does not work. Tested it 3 x now with a big xml file and it fails every time. Reverted back to the old function

    I consolidate errors in creation of WXR_Parser object, obsolete calling of bump_request_timeout() and wp_get_http() methods in WP4.4+. You can replace files parsers.php and wordpress-importer.php by files from this archive: http://wikisend.com/download/364850/wordpress-importer-4-4.zip

    Can you please share this solution?

    Tevya

    (@thefiddler)

    @jubba2001 can you reshare the files? Or paste the code in there? I’m looking for a solution to get my images moved over.

    Angelo Rocha

    (@angelorocha)

    @jubba2001 pls reshare file.
    thanks.

    ptasker

    (@ptasker)

    Just to note, there is a Trac ticket in for this. I’ve mentioned that there is an ongoing issue with this plugin and I’ve witnessed it myself. It’s generally not a good idea to override core plugins with your own code, though I do understand the frustration.

    ptasker

    (@ptasker)

    Head’s up that this is also in the works, an importer via the WP-CLI https://github.com/humanmade/WordPress-Importer. Not final yet but may work.

    Tevya

    (@thefiddler)

    I saw that in my searched @ptasker. But I don’t want to go through all the trouble of setting up CLI and learning how it works, just to do an occasional import. I couldn’t find any updates related to that plugin for several months at least now. It’s like it got dropped 🙁

    Plugin Author Ryan McCue

    (@rmccue)

    It’s like it got dropped 🙁

    Not dropped, just in hibernation, as my focus is split across a lot of different projects. The beta importer now has admin UI in the works and coming soon, see this pull request for more about that. I’ll be writing an update about it soon.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Notice: wp_get_http is deprecated since version 4.4!’ is closed to new replies.