Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Uncaught ImfsException: [0]: Duplicate entry '0' for key 'option_id' in ALTER TABLE [...] #80

Open
Znuff opened this issue Jun 12, 2024 · 0 comments

Comments

@Znuff
Copy link

Znuff commented Jun 12, 2024

Hello,

While running

wp index-mysql enable --all --dry-run

This attempts to create a unique key on option_id:

Index WP MySQL For Speed 1.4.18
Versions  Plugin:1.4.18 MySQL:10.11.7-MariaDB-1:10.11.7+maria~ubu2204 WordPress:6.5.4 WordPress database:57155 php:8.0.30
WordPress database error Duplicate entry '0' for key 'option_id' for query ALTER TABLE `zs_options` ADD UNIQUE KEY option_id (option_id), ADD PRIMARY KEY (option_name), DROP KEY option_name, DROP KEY autoload_2, DROP KEY autoload_3, DROP KEY autoload_4/**imfs-query-tag*394371712*/ made by include('phar:///usr/local/bin/wp/php/boot-phar.php'), include('phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php'), WP_CLI\bootstrap, WP_CLI\Bootstrap\LaunchRunner->process, WP_CLI\Runner->start, WP_CLI\Runner->run_command_and_exit, WP_CLI\Runner->run_command, WP_CLI\Dispatcher\Subcommand->invoke, call_user_func, WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}, call_user_func, ImsfCli->enable, ImsfCli->doRekeying, ImfsDb->rekeyTables, ImfsDb->rekeyTable, ImfsDb->query
PHP Fatal error:  Uncaught ImfsException: [0]: Duplicate entry '0' for key 'option_id' in ALTER TABLE `zs_options` ADD UNIQUE KEY option_id (option_id), ADD PRIMARY KEY (option_name), DROP KEY option_name, DROP KEY autoload_2, DROP KEY autoload_3, DROP KEY autoload_4/**imfs-query-tag*394371712*/

Looking at my database structure, there seems to be A LOT of options with the option_id=0:

MariaDB > select count(*) from zs_options where option_id=0 \G
*************************** 1. row ***************************
count(*): 922
1 row in set (0.001 sec)

Looking at the entries in zs_options, there seem so be A LOT of different plugins that, over the years, have inserted an option with id=0.

This is a very very old Wordpress install (originating from 19-ish years ago?) .

I'm assuming that somewhere along the lines the _options table has received a auto_increment on the option_id column, but the damage was probably already done so that the schema alteration never took place on this table (because there were always duplicate keys).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant