Fixed XF2.1 upgrade error

Affected version
2.1.1

Xon

Well-known member
On testing the XF2 upgrade process for spacebattles, I hit this error;
Code:
Running upgrade to 2.1.0 Alpha, step 43...
In AbstractStatement.php line 217:

  [XF\Db\Exception (1264)]
  xf_user: MySQL query error [1264]: Out of range value for column 'reaction_score' at row 99


Exception trace:
() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Db/AbstractStatement.php:217
XF\Db\AbstractStatement->getException() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Db/Mysqli/Statement.php:196
XF\Db\Mysqli\Statement->getException() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Db/Mysqli/Statement.php:77
XF\Db\Mysqli\Statement->execute() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Db/AbstractAdapter.php:94
XF\Db\AbstractAdapter->query() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Db/Schema/AbstractDdl.php:151
XF\Db\Schema\AbstractDdl->apply() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Db/SchemaManager.php:149
XF\Db\SchemaManager->alterTable() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Install/InstallHelperTrait.php:594
XF\Install\Upgrade\AbstractUpgrade->alterTable() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Install/Upgrade/2010010-210a.php:665
XF\Install\Upgrade\Version2010010->step43() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Cli/Command/Upgrade.php:134
XF\Cli\Command\Upgrade->execute() at /var/www/sites/xf2.spacebattles.com/html/src/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/sites/xf2.spacebattles.com/html/src/vendor/symfony/console/Application.php:953
Symfony\Component\Console\Application->doRunCommand() at /var/www/sites/xf2.spacebattles.com/html/src/vendor/symfony/console/Application.php:248
Symfony\Component\Console\Application->doRun() at /var/www/sites/xf2.spacebattles.com/html/src/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /var/www/sites/xf2.spacebattles.com/html/src/XF/Cli/Runner.php:63
XF\Cli\Runner->run() at /var/www/sites/xf2.spacebattles.com/html/cmd.php:15
Code:
public function step43()
{
   if (!$this->schemaManager()->columnExists('xf_user', 'like_count'))
   {
      // column is gone, so assume this has been run
      return;
   }

   $this->alterTable('xf_user', function (Alter $table)
   {
      $table->changeColumn('like_count')->renameTo('reaction_score')->unsigned(false);
      $table->dropIndexes('like_count');
      $table->addKey('reaction_score');
   });
}
The column like_count has the definition;
Code:
`like_count` int(10) unsigned NOT NULL DEFAULT 0
The SQL it tries to run is;
SQL:
ALTER TABLE `xf_user`
CHANGE COLUMN `like_count` `reaction_score` INT NOT NULL DEFAULT '0',
DROP INDEX `like_count`,
ADD KEY `reaction_score` (`reaction_score`)
 
Last edited:

Xon

Well-known member
I see the issue, someone was smart and modified a user record (cia admincp) with +3 billion likes (specifically to π, with a bunch digits), meaning changing from an unsigned to a signed integer error'ed.
 
Last edited:

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.2).

Change log:
Prevent an out of range MySQL error when upgrading to XF 2.1.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Top