Duplicate Error installing on PHP 7.2

Jon W

Well-known member
Affected version
1.5.13
Same bug as noted here:
https://xenforo.com/community/threads/error-when-installing-1-5-8.152315/
but the solution given on that page is wrong as the solution solves a bug from upgrading to XF2.

The error is:

count(): Parameter must be an array or an object that implements Countable
  1. XenForo_Application::handlePhpError() in XenForo/Install/Model/Install.php at line 283
  2. XenForo_Install_Model_Install->insertDefaultData() in XenForo/Install/Controller/Install.php at line 219
  3. XenForo_Install_Controller_Install->actionStep2() in XenForo/FrontController.php at line 351
  4. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
  5. XenForo_FrontController->run() in /var/www/public/xfaddons/install/index.php at line 18
The bug seems to be in the insertDefaultData function on line 283, which is doing a count on $data for some weird reason. The return value isn't actually necessary, so just replace:
PHP:
    public function insertDefaultData()
    {
        $db = $this->_getDb();

        $insertData = XenForo_Install_Data_MySql::getData();
        foreach ($insertData AS $data)
        {
            $db->query($data);
        }

        return count($data);
    }
with:
PHP:
    public function insertDefaultData()
    {
        $db = $this->_getDb();

        $insertData = XenForo_Install_Data_MySql::getData();
        foreach ($insertData AS $data)
        {
            $db->query($data);
        }
    }
 
Oops, didn't realise I was so out of date. I saw August 2018 on that other post and assumed I was relatively up to date.
 
Back
Top Bottom