MantisBT - Piwigo
View Issue Details
0003078Piwigopluginspublic2014.05.09 16:402014.10.06 12:58
Apache 2.4.x
0003078: ZLib issues on Ubuntu (and other OS's)
When I installed Piwigo and then tried to install some plugins, I kept getting the message:

    Abort pclzip.lib.php : Missing zlib extensions

Running `php -m` showed that the Zlib extension was, in fact, installed.

This is similar to the problem mentioned in this topic (though the solution proposed in that topic does not work for the reason claimed - it actually works because PHP is compiled against a different version of Zlib.)

The root of the problem lies in the fact that PHP compiled with "large file support" (as PHP on new Ubuntu installs is compiled) names the function `gzopen` as `gzopen64` instead. Piwigo looks for the original function name, and then complains when it cannot be found.

The simplest solution for this problem is to check whether the function exists, and to alias it if it does not. For example, like this:

    if (!extension_loaded('zlib'))
      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
    if (!function_exists('gzopen') && function_exists('gzopen64'))
      function gzopen(string $filename , string $mode, int $use_include_path = 0) {
        return gzopen64($filename, $mode, $use_include_path)

Another way to do it would be to use a function pointer, like this:

    if (!extension_loaded('zlib'))
      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
    if (function_exists('gzopen'))
      $this->gzopen_func = 'gzopen';
    elseif (function_exists('gzopen64'))
      $this->gzopen_func = 'gzopen64';
      die('Abort '.basename(__FILE__).' : Could not find gzopen');

Then, instead of saying `gzopen(...)`, you would use this:

    $gzopen = $this->gzopen_func;

(Note that this could probably be done in a single line - I just did it in two lines for clarity about what points where.)

Note that I had this issue on Ubuntu, but I found similar reports about gzopen64 on many platforms.
No tags attached.
Issue History
2014.05.09 16:40kohenkatzNew Issue
2014.05.09 16:40kohenkatzbrowser => any
2014.05.09 16:40kohenkatzDatabase engine and version => 5.5.37-MariaDB-1~trusty-log
2014.05.09 16:40kohenkatzPHP version => 5.5.9-1ubuntu4
2014.05.09 16:40kohenkatzWeb server => Apache 2.4.x
2014.05.12 13:43plgAssigned To => plg
2014.05.12 13:43plgStatusnew => assigned
2014.05.12 13:43plgTarget Version => 2.6.3
2014.06.11 09:53plgTarget Version2.6.3 => 2.6.4
2014.08.10 08:30plgTarget Version2.6.4 => 2.7.0beta3
2014.08.24 18:55plgTarget Version2.7.0RC1 => 2.7.0RC2
2014.09.16 12:00plgTarget Version2.7.0RC2 => 2.7.0
2014.09.24 09:49plgTarget Version2.7.0 => 2.7.1
2014.10.06 12:45svnCheckin
2014.10.06 12:45svnNote Added: 0007670
2014.10.06 12:46svnCheckin
2014.10.06 12:46svnNote Added: 0007671
2014.10.06 12:58plgStatusassigned => closed
2014.10.06 12:58plgResolutionopen => fixed
2014.10.06 12:58plgFixed in Version => 2.7.1

2014.10.06 12:45   
[Subversion] r29904 by plg on trunk

-----[Subversion commit log]----------------------------------------------------
bug 3078: avoid zlib issue on Ubuntu 14.04 (PHP 5.5) and maybe other systems
2014.10.06 12:46   
[Subversion] r29905 by plg on branch 2.7

-----[Subversion commit log]----------------------------------------------------
merge r29904 from trunk to branch 2.7

bug 3078: avoid zlib issue on Ubuntu 14.04 (PHP 5.5) and maybe other systems