Menu

#17 PHP version requirements fix

open
nobody
core (13)
7
2005-03-03
2005-03-03
No

In adodb-xmlschema.inc.php on line 1732, you use the
function file_get_contents.

That pushes the php version requirements up to 4.3+,
far beyond the requirements of adodb itself.

While it only triggers when the schema version doesnt
match the current schema version for adodb-xmlschema,
its still a requirement escalation.

I recommend following the suggestion in the user
comments at
http://us2.php.net/manual/en/function.file-get-contents.php
, and adding a function check and if its not available,
making a backwards-compatible replacement (code is
included at that site).

Its only 6 additional lines of code, and it puts
adodb-xmlschema back to the same requirements as adodb,
as far as I can tell.

Discussion

  • Anonymous

    Anonymous - 2005-03-03
    • priority: 5 --> 7
     
  • Richard Tango-Lowy

    • labels: --> core
     
  • Richard Tango-Lowy

    Logged In: YES
    user_id=302293

    Good suggestion. I'll take a look at it.

     
  • Andrew Eddie

    Andrew Eddie - 2005-06-06

    Logged In: YES
    user_id=507145

    Use this function from the PEAR PHP_Compat project:

    /**
    * Replace file_get_contents()
    *
    * @category PHP
    * @package PHP_Compat
    * @link http://php.net/function.file_get_contents
    * @author Aidan Lister <aidan@php.net>
    * @version $Revision: 1.2 $
    * @internal resource_context is not supported
    * @since PHP 5
    * @require PHP 4.0.1 (trigger_error)
    */
    if (!function_exists('file_get_contents')) {
    function file_get_contents($filename, $incpath = false,
    $resource_context = null)
    {
    if (false === $fh = fopen($filename, 'rb', $incpath)) {
    trigger_error('file_get_contents() failed to
    open stream: No such file or directory', E_USER_WARNING);
    return false;
    }

    clearstatcache();
    if ($fsize = @filesize($filename)) {
    $data = fread($fh, $fsize);
    } else {
    $data = '';
    while (!feof($fh)) {
    $data .= fread($fh, 8192);
    }
    }

    fclose($fh);
    return $data;
    }
    }

     
  • Anonymous

    Anonymous - 2005-10-15

    Logged In: YES
    user_id=528997

    eddie, that code (the PHP_Compat code) is under the PHPL,
    whereas the code I referenced is public domain. Since the
    PHPL isn't compatible with the license for adodb (its far
    more restrictive), its better to simply use the code I
    referenced. Plus, its smaller. :)

     

Log in to post a comment.