Fixed Upgrade error 1.1.16 -> 2.0.4

cellarius

Well-known member
I get the following error when upgrading the Media Gallery from 1.1.16 to 2.0.4:

XF\Db\InvalidQueryException: MySQL statement prepare error [1101]: BLOB/TEXT column 'view_user_groups' can't have a default value in src/XF/Db/AbstractStatement.php at line 212
  1. XF\Db\AbstractStatement->getException() in src/XF/Db/Mysqli/Statement.php at line 196
  2. XF\Db\Mysqli\Statement->getException() in src/XF/Db/Mysqli/Statement.php at line 40
  3. XF\Db\Mysqli\Statement->prepare() in src/XF/Db/Mysqli/Statement.php at line 54
  4. XF\Db\Mysqli\Statement->execute() in src/XF/Db/AbstractAdapter.php at line 79
  5. XF\Db\AbstractAdapter->query() in src/XF/Db/Schema/AbstractDdl.php at line 151
  6. XF\Db\Schema\AbstractDdl->apply() in src/XF/Db/SchemaManager.php at line 143
  7. XF\Db\SchemaManager->alterTable() in src/addons/XFMG/Setup.php at line 644
  8. XFMG\Setup->upgrade902000010Step3() in src/XF/AddOn/StepRunnerUpgradeTrait.php at line 122
  9. XFMG\Setup->upgradeStepRunner() in src/XF/AddOn/StepRunnerUpgradeTrait.php at line 71
  10. XFMG\Setup->upgrade() in src/XF/Admin/Controller/AddOn.php at line 449
  11. XF\Admin\Controller\AddOn->actionUpgrade() in src/XF/Mvc/Dispatcher.php at line 249
  12. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 89
  13. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
  14. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1891
  15. XF\App->run() in src/XF.php at line 328
  16. XF::runApp() in admin.php at line 13

Any ideas why that would be, and what to do about it?
 
We spotted this yesterday and fixed it.

To fix it yourself you'll need to edit src/addons/XFMG/Setup.php.

Find:
PHP:
$table->addColumn('view_user_groups', 'blob')->setDefault('a:1:{i:0;i:-1;}')->after('category_description');

And replace with:
PHP:
$table->addColumn('view_user_groups', 'blob')->after('category_description');

That section of code should then look like this:
PHP:
$sm->alterTable('xf_mg_category', function(Alter $table)
{
   $table->addColumn('view_user_groups', 'blob')->after('category_description');
});

Directly below that add:
PHP:
$this->query("
   UPDATE xf_mg_category
   SET view_user_groups = ?
", 'a:1:{i:0;i:-1;}');
 
Back
Top Bottom