Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.76k stars 888 forks source link

Testing indexables (14.0-RC7) - Fatal error on missing table wp_yoast_indexable #14918

Closed Djennez closed 4 years ago

Djennez commented 4 years ago

I think this is an edge case, and I am not sure if it's worth fixing.

To reproduce:

  1. Install Yoast 14.0-RC7

  2. Make sure the site works as expected. Observe the table wp_yoast_indexable in the database exists.

  3. Delete this table

  4. Navigate to the plugins-page, front-end or SEO page from your website, all will throw the following error:

    Uncaught Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wordpress.wp_yoast_indexable' doesn't exist in /var/www/html/wp-content/plugins/wordpress-seo/vendor_prefixed/j4mie/idiorm/idiorm.php on line 464
  5. Deactivate the plugin (either via sFTP or WP-CLI). Note the error is gone.

  6. Re-activate the plugin, the error is back (so activation does not re-create the table)

Observable optional steps:

  1. Remove the yoast_migrations_free entry from wp_options and reload a page with an error, the page should load fine, but any further reloads will throw the error again.

  2. Manually create a table wp_yoast_indexable in the database.

  3. Refresh a page with the error. The error should now read:

    Uncaught Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'object_type' in 'where clause' in /var/www/html/wp-content/plugins/wordpress-seo/vendor_prefixed/j4mie/idiorm/idiorm.php on line 464

In comparison: manually remove wp_yoast_seo_links. No errors are shown and deactivating and activating the plugin again will restore this table.

Complete stacktrace of the initial error:

Uncaught Exception: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wordpress.wp_yoast_indexable' doesn't exist in /var/www/html/wp-content/plugins/wordpress-seo/vendor_prefixed/j4mie/idiorm/idiorm.php on line 464

    execute()
    wp-content/plugins/wordpress-seo/vendor_prefixed/j4mie/idiorm/idiorm.php:464
    _execute()
    wp-content/plugins/wordpress-seo/vendor_prefixed/j4mie/idiorm/idiorm.php:1804
    _run()
    wp-content/plugins/wordpress-seo/src/orm/yoast-orm-wrapper.php:231
    _run()
    wp-content/plugins/wordpress-seo/vendor_prefixed/j4mie/idiorm/idiorm.php:633
    find_one()
    wp-content/plugins/wordpress-seo/src/orm/yoast-orm-wrapper.php:135
    find_one()
    wp-content/plugins/wordpress-seo/src/repositories/indexable-repository.php:264
    find_for_system_page()
    wp-content/plugins/wordpress-seo/src/actions/indexation/indexable-general-indexation-action.php:92
    query()
    wp-content/plugins/wordpress-seo/src/actions/indexation/indexable-general-indexation-action.php:47
    get_total_unindexed()
    wp-content/plugins/wordpress-seo/src/integrations/admin/indexation-integration.php:212
    get_total_unindexed()
    wp-content/plugins/wordpress-seo/src/integrations/admin/indexation-integration.php:132
    enqueue_scripts()
    wp-includes/class-wp-hook.php:287
    apply_filters()
    wp-includes/class-wp-hook.php:311
    do_action()
    wp-includes/plugin.php:478
    do_action()
    wp-admin/admin-header.php:104
    require_once()
    wp-admin/plugins.php:486
IreneStr commented 4 years ago

Solution: catch the exception and show this warning: https://github.com/Yoast/wordpress-seo/pull/14903/files#diff-1e3f94f34573cfe3f34d72caa6013d0eR23

herregroen commented 4 years ago

@IreneStr I don't think the notification is the appropriate one to show here.

That concerns us not being able to create tables. In this case we can create tables, we did successfully create the tables but someone removed them afterwards.

If we want to catch this we should show a different notice, probably one instructing people to install the test helper and reset their tables.

That said I'm not entirely sure this is worth fixing as I don't know how anyone would get into this situation without explicitly doing stuff that explicitly breaks your site.

igorschoester commented 4 years ago

Joost decided to not fix this, closing the issue.