babble icon indicating copy to clipboard operation
babble copied to clipboard

404 after fresh install on WP 4.5.3

Open khromov opened this issue 8 years ago • 1 comments

404 on all pages on frontend that use the // prefixes in url, ie site.com/en/page

Seems like Rewrite Rules are broken, checked with Rewrite Rules Inspector:

2016-07-13 10_51_36-rewrite rules inspector wp stable wordpress

khromov avatar Jul 13 '16 08:07 khromov

The issue is caused by the fact that the filter "pre_update_option_rewrite_rules" is employed in order to switch the rewrite rules to those needed by the plugin (class-locale.php:85).

The issue occurs after updates done in the context of ticket https://core.trac.wordpress.org/ticket/29107, WP milestone 4.5. Instead of deleting the rewrite_rules option, it is set to an empty string. Thus, the pre_update_option_rewrite_rules filter is called upon flush and, instead of having an empty option stored in the DB, the value ends up to be a:2:{i:0;s:0:"";s:12:"robots\.txt$";s:18:"index.php?robots=1";} as set in class-locale.php:198.

Next up in the flush process, after storing the above value in the DB, the method wp_rewrite_rules is called, which first checks if the rewrite_rules option is empty, prior to repopulating it with the current set of rules. Because the option is non-empty, the option does not get updated.

My fix was to switch from using the pre_update_option_rewrite_rules to using the rewrite_rules_array filter in class-locale.php:85, as is the case on the develop branch: add_filter( 'rewrite_rules_array', array( $this, 'filter_rewrite_rules_array' ), 999 );

I believe this update must be merged from the develop branch to the master branch.

mariusveltan avatar Aug 02 '16 19:08 mariusveltan