Fixed Index conflict resolution with partial indexes is broken

Xon

Well-known member
Affected version
2.0.10
Trying to install version 2.0.0 Beta 2, but getting this error when hitting the Install button:

ErrorException: [E_WARNING] Illegal offset type in isset or empty in src/XF/Db/Schema/Index.php at line 191
  1. XF::handlePhpError() in src/XF/Db/Schema/Index.php at line 191
  2. XF\Db\Schema\Index->getDefinition() in src/XF/Db/Schema/Alter.php at line 254
  3. XF\Db\Schema\Alter->getQueries() in src/XF/Db/Schema/AbstractDdl.php at line 147
  4. XF\Db\Schema\AbstractDdl->apply() in src/XF/Db/SchemaManager.php at line 143
  5. XF\Db\SchemaManager->alterTable() in src/addons/AVForums/TagEssentials/Setup.php at line 34
  6. AVForums\TagEssentials\Setup->installStep1() in src/XF/AddOn/StepRunnerInstallTrait.php at line 60
  7. AVForums\TagEssentials\Setup->installStepRunner() in src/XF/AddOn/StepRunnerInstallTrait.php at line 27
  8. AVForums\TagEssentials\Setup->install() in src/XF/Admin/Controller/AddOn.php at line 393
  9. XF\Admin\Controller\AddOn->actionInstall() in src/XF/Mvc/Dispatcher.php at line 249
  10. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 88
  11. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
  12. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1931
  13. XF\App->run() in src/XF.php at line 329
  14. XF::runApp() in admin.php at line 13

Caused by the effective following code;
PHP:
public function installStep1()
{
$this->schemaManager()->createTable('xf_tagess_blacklist', function (Create $table) {
    $table->addColumn('blacklist_id', 'int')->autoIncrement()->primaryKey();
    $table->addColumn('tag', 'varchar', 255);
    $table->addColumn('regex', 'tinyint', 1)->setDefault(0);
    $table->addColumn('user_id', 'int');
    $table->addColumn('blacklisted_date', 'int')->nullable(true)->setDefault(null);
    $table->addKey(['regex',['tag', 191]], 'tag');
});
$this->schemaManager()->alterTable('xf_tagess_blacklist', function (Alter $table) {
    $table->addKey(['regex',['tag', 191]], 'tag');
});
}

Normally this would update/change the index 'tag', but with a partial index the column definition is returned as ['regex',['tag', 191]] which causes the test if (isset($conflictRenames[$column])) to fail with "Illegal offset type in isset or empty".

I require the partial index to support older version of MySQL which do not support index over columns longer than 255 bytes.
 
Last edited:
Thank you for reporting this issue. The issue is now resolved and we are aiming to include that in a future XF release (2.0.12).

Change log:
Add support for partial indexes to schema manager conflict resolution system
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 
Back
Top Bottom