[wp-trac] [WordPress Trac] #17756: class-feed.php file_get_contents error

WordPress Trac wp-trac at lists.automattic.com
Sat Jun 11 03:31:18 UTC 2011


#17756: class-feed.php file_get_contents error
--------------------------+------------------------------
 Reporter:  kmfj1         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Cache         |     Version:  3.2
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |
--------------------------+------------------------------
Changes (by dd32):

 * component:  Administration => Cache


Old description:

> I removed my feed URL from the dashboard incoming links through the
> configuration. When I go back to view Incoming Links I get a file not
> found error in file_get_contents in class-feed.php on about line 88.
>
> Warning: file_get_contents(http:) [function.file-get-contents]: failed to
> open stream: Invalid argument in C:\_vhosts\xxx\xxx\wp-includes\class-
> feed.php on line 88
>
> RSS Error: file_get_contents could not read the file
>
> file_get_contents can't open the non-existent URL (http:), which causes
> the PHP error. If the script used file_exists before file_get_contents
> this should fix the issue? This is not a SimplePie issue but the extended
> class: WP_Feed_Cache
>
> I changed to:
>
>     if(!file_exists($url)){
>
>         $this->error = 'the file doesn\'t exist could not read the file';
> $this->success = false;
>
>     } else{
>
>         if ( ! $this->body = file_get_contents($url) ) {
>         $this->error = 'file_get_contents could not read the file';
> $this->success = false;
>
>         }
>
>     }
>
> This fixed the issue?

New description:

 I removed my feed URL from the dashboard incoming links through the
 configuration. When I go back to view Incoming Links I get a file not
 found error in file_get_contents in class-feed.php on about line 88.

 Warning: file_get_contents(http:) [function.file-get-contents]: failed to
 open stream: Invalid argument in C:\_vhosts\xxx\xxx\wp-includes\class-
 feed.php on line 88

 RSS Error: file_get_contents could not read the file

 file_get_contents can't open the non-existent URL (http:), which causes
 the PHP error. If the script used file_exists before file_get_contents
 this should fix the issue? This is not a SimplePie issue but the extended
 class: WP_Feed_Cache

 I changed to:
 {{{
     if(!file_exists($url)){

         $this->error = 'the file doesn\'t exist could not read the file';
 $this->success = false;

     } else{

         if ( ! $this->body = file_get_contents($url) ) {
         $this->error = 'file_get_contents could not read the file';
 $this->success = false;

         }

     }
 }}}
 This fixed the issue?

--

Comment:

 The reason this is fitting a file_get_contents() call is because it
 assumes it's a local file. This is because it doesn't recognise that as a
 URL, as it doesn't match the pattern http(s)?://

 Seems worthwhile changing that to something like the following, I'm not
 sure if we need another string for it, not that these strings are
 translated anyway
 {{{
 if ( ! file_exists($url) || ( ! $this->body = file_get_contents($url) ) )
 {
         $this->error = 'file_get_contents could not read the file';
         $this->success = false;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17756#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list