Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#2319 closed defect (bug) (fixed)

file_get_contents is PHP 4.3+, docs says PHP 4.2 ok

Reported by: Ozh Owned by: ryan
Priority: normal Milestone:
Component: General Version: 2.0
Severity: blocker Keywords: PHP 4.2 file_get_contents
Cc:

Description

cache.php uses function file_get_contents with is PHP 4.3+ when docs says that minimum requirement is 4.2
Either upgrade doc, or for maximum compatibility with obsolete install like errrr mine, add somewhere :

if (!function_exists('file_get_contents')) {
        function file_get_contents($file) {
                return implode('',file($file));
        }
}

Change History (7)

comment:1   ryan7 years ago

  • Owner changed from anonymous to ryan

We could just add that into functions-compat.php. file_get_contents() is a damn useful function, and it's a lot more readable than implode(, file(...)), so a suitable compat function candidate, I think.

comment:3   ryan7 years ago

Agreed.

This is what I've been using in one of my plugins... not sure where I got it:

/* compatibility with PHP versions older than 4.3 */
if ( !function_exists('file_get_contents') ) {
   function file_get_contents($file) {
       $file = file($file);
       return !$file ? false : implode('', $file);
   }
}

I don't think implode will return false, which is why you need that extra line

comment:6   matt7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [3471]) Compat function, fixes #2319

  • Milestone 2.0.1 deleted

Milestone 2.0.1 deleted

Note: See TracTickets for help on using tickets.