Cms: Backup database fails to download zip under PHP 7.1

Created on 12 Apr 2017  路  4Comments  路  Source: craftcms/cms

Description

Selecting 'Backup Database' under Settings appears to succeed but nothing is downloaded.

The server log shows an error zipping the SQL:

2017/04/11 15:39:18 [error] [php] A non well formed numeric value encountered (/var/www/craft/app/vendor/pclzip/pclzip/pclzip.lib.php:1797)
Stack trace:
#0 /var/www/craft/app/etc/io/PclZip.php(193): PclZip->add()
#1 /var/www/craft/app/etc/io/Zip.php(136): Craft\PclZip->add()
#2 /var/www/craft/app/tools/DbBackupTool.php(77): add()
#3 /var/www/craft/app/controllers/ToolsController.php(50): Craft\DbBackupTool->performAction()
#4 /var/www/craft/app/framework/web/actions/CInlineAction.php(49): Craft\ToolsController->actionPerformAction()
#5 /var/www/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams()
#6 /var/www/craft/app/framework/web/CController.php(286): Craft\ToolsController->runAction()
#7 /var/www/craft/app/framework/web/CController.php(265): Craft\ToolsController->runActionWithFilters()
#8 /var/www/craft/app/framework/web/CWebApplication.php(282): Craft\ToolsController->run()
#9 /var/www/craft/app/etc/web/WebApp.php(817): Craft\WebApp->runController()
#10 /var/www/craft/app/etc/web/WebApp.php(287): Craft\WebApp->_processActionRequest()
#11 /var/www/craft/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#12 /var/www/craft/app/index.php(62): Craft\WebApp->run()
#13 /var/www/html/index.php(19): require_once()
REQUEST_URI=/index.php/admin/actions/tools/performAction
in /var/www/craft/app/etc/web/WebApp.php (687)
in /var/www/craft/app/vendor/pclzip/pclzip/pclzip.lib.php (1797)
in /var/www/craft/app/vendor/pclzip/pclzip/pclzip.lib.php (513)

Presumably this is due to the PHP 7.1 feature: https://wiki.php.net/rfc/invalid_strings_in_arithmetic

Downgrading to PHP 7.0 works around the problem.

Steps to reproduce

  1. Run Craft CMS under PHP 7.1
  2. Select 'Backup Database' under Settings
  3. No zip file is downloaded

Additional info

  • Craft version: 2.6.2971
  • PHP version: 7.1.3
  • Database driver & version: pdo_mysql
  • Plugins & versions: N/A
wontfix

Most helpful comment

Craft 2 bundles PclZip as a fallback zip library to use if ZipArchive isn't installed on the box. Unfortunately that PclZip class hasn't been updated since 2009 and is not PHP 7.1 compatible.

For Craft 2, the workaround is to install ZipArchive on your box if you want to use PHP 7.1 and Craft will use it automatically. For Craft 3, we've removed the PclZip fallback and just require ZipArchive.

All 4 comments

Craft 2 bundles PclZip as a fallback zip library to use if ZipArchive isn't installed on the box. Unfortunately that PclZip class hasn't been updated since 2009 and is not PHP 7.1 compatible.

For Craft 2, the workaround is to install ZipArchive on your box if you want to use PHP 7.1 and Craft will use it automatically. For Craft 3, we've removed the PclZip fallback and just require ZipArchive.

Thanks, I'll give that a go. Should this be documented on Requirements?

Probably... there are several PHP 7.1 gotchas like this. I think we're just going to write a support article that addresses them all.

Craft 2.6.2994 added a PHP 7.1 compatible version of PclZip, so it should happen for any subsequent release, but we'd still recommend just installing ZipArchive.

Was this page helpful?
0 / 5 - 0 ratings