joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.72k stars 3.64k forks source link

J3.9.23 -> Extensions installation fails because of Timeouts #31506

Closed ufuk-avcu closed 3 years ago

ufuk-avcu commented 3 years ago

Steps to reproduce the issue

Use the newest Joomla 3.9.23 Install for example Yootheme Pro Package. (important: This package includes more Zips within the zip File and this seems to be the problem. If the zip doesn't contains other zips, the installation times are as usual.)

Expected result

Installation complete after several seconds. Tested with Joomla 3.9.22 -> 15 seconds for installation.

Actual result

Installation takes minutes or fail: Maximum execution time of 60 seconds exceeded in /libraries/vendor/joomla/archive/src/Zip.php on line 301 With higher exexcution Time settings the installation takes 2:05 minutes.

System information (as much as possible)

Joomla 3.9.23 Tested it with Yootheme Pro 2.3.19 (7,3 MB) -> takes long. Zip in zips. Tested with oder extensions without zips in zip ist fast and as excepted.

Conlusion

Joomla 3.9.23 -> 2:05 Minutes Joomla 3.9.22 -> 0:15 Minutes -> for the same extension.

nibra commented 3 years ago

The joomla-framework/archive package has been updated to use the PHP ZipArchive, because the zip functions we used before are deprecated in favor of the Object API.

This is an issue that we inherited from PHP, so we can't do much about it. Nevertheless we'll investigate the possibility of a workaround. Can't promise anything, though.

ufuk-avcu commented 3 years ago

Tested it also with Akeeba Backup Core. The main zip contains, 6 other zips. But there are no problems here. The installation speed is more or less the same.

steffans commented 3 years ago

This resolves the issue for me, use directly ZipArchive::getFromIndex instead of first getting and reading the file with ZipArchive::getStream. This should happen with all larger zip files because the read operation takes longer.

    /**
     * Extract a ZIP compressed file to a given path using native php api calls for speed
     *
     * @param   string  $archive      Path to ZIP archive to extract
     * @param   string  $destination  Path to extract archive into
     *
     * @return  boolean  True on success
     *
     * @since   1.0
     * @throws  \RuntimeException
     */
    protected function extractNative($archive, $destination)
    {
        $zip = new \ZipArchive;

        if ($zip->open($archive) !== true)
        {
            throw new \RuntimeException('Unable to open archive');
        }

        // Make sure the destination folder exists
        if (!Folder::create($destination))
        {
            throw new \RuntimeException('Unable to create destination folder ' . \dirname($path));
        }

        // Read files in the archive
        for ($index = 0; $index < $zip->numFiles; $index++)
        {
            $file = $zip->getNameIndex($index);

            if (substr($file, -1) === '/')
            {
                continue;
            }

            $buffer = $zip->getFromIndex($index);

            if ($buffer === false)
            {
                throw new \RuntimeException('Unable to read ZIP entry');
            }

            if (File::write($destination . '/' . $file, $buffer) === false)
            {
                throw new \RuntimeException('Unable to write ZIP entry to file ' . $destination . '/' . $file);
            }
        }

        $zip->close();

        return true;
    }
ufuk-avcu commented 3 years ago

@steffans Tested your code with 3.9.23 and now it takes also 15 seconds.

HLeithner commented 3 years ago

@steffans can you make a PR against https://github.com/joomla-framework/archive ?

HLeithner commented 3 years ago

or @nibra will you create the PR?

nibra commented 3 years ago

PR is ready: https://github.com/joomla-framework/archive/pull/24

richard67 commented 3 years ago

@HLeithner We leave this issue open until the framework PR has been merged and we will have a PR for updating the framework package in staging, right?

HLeithner commented 3 years ago

yes please

vingle commented 3 years ago

I have the same issue - also emerged on an attempted YTPro upgrade.

Tested the same upgrade on a 3.9.22 (fine) and 3.9.23 (timed out with a 500 second limit). Zoolanders Essentials timesout too - but other extensions have loaded ok. The issue is the same whether using the update script, installing from a directory, or uploading the package file.

I tried applying the patch from the PR to libraries/joomla/archive/zip.php - but unless I need to delete a cache or something, it didn't make any difference.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31506.

ufuk-avcu commented 3 years ago

@vingle This is the correct directory: joomla_root/libraries/vendor/joomla/archive/src/Zip.php


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31506.

vingle commented 3 years ago

Ah - thanks for the correction – yes that works for me now :)

paoprod commented 3 years ago

Just to confirm...

HLeithner commented 3 years ago

thx I keep this issue open until 3.9.24 is released

Stevec4 commented 3 years ago

I applied the patch to the zip.php, and tried updating from yootheme j3_2.3.21 to yootheme j3_2.3.23 and 24 both fail with an unable to find manifest file. I re-uploaded the unchanged zip.php file and the update for yootheme pro installed fine.

Joomla 3.9.23 PHP 7.4.11


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/31506.

HLeithner commented 3 years ago

@Stevec4 did you tested https://github.com/joomla/joomla-cms/pull/31514 ?

Stevec4 commented 3 years ago

Sorry I wasn't clear Harald, the patch I applied was from the #31514 PR.

Steve

HLeithner commented 3 years ago

@Stevec4 please test https://github.com/joomla/joomla-cms/releases/tag/3.9.24-rc I'm closing this because this should be solved

Stevec4 commented 3 years ago
Message
Installation of the package was successful.

With the RC installed it worked perfectly Harald

HLeithner commented 3 years ago

Thanks for the feedback

PhilETaylor commented 3 years ago

Tested 3.9.24RC will all the largest packages like com_easyblog 5.4.6 which is 13.5Mb... and com_jomsocial 4.7.7 which is 12.9Mb packages and its all ok for me.

HLeithner commented 3 years ago

thanks for the report @PhilETaylor