Make WordPress Core

Opened 9 years ago

Last modified 6 years ago

#36915 new defect (bug)

Permalinks broken after 4.5 Rewrite rules

Reported by: fatorbinario's profile fatorbinario Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5
Component: Rewrite Rules Keywords:
Focuses: Cc:

Description

Hi guys,
Some of my websites had the permalinks broken after upgrading to 4.5.

My webserver is NginX and the theme is iMedica.

How I fixed:
============

This file: /wp-includes/class-wp-rewrite.php
Line: 1813: "update_option( 'rewrite_rules', );"

Before 4.5 that line was "delete_option('rewrite_rules');"

But I think when WP team changed to update_option function they missed a parameter, it should be:
"update_option('rewrite_rules', $this->rules);"

After fixing this the permalink started working again.

Change History (4)

#1 @swissspidy
9 years ago

Hey there, thanks for your report!

This was introduced in [36254], see #29107.

The line in question was changed to update_option( 'rewrite_rules', '' ); on purpose. That function should flush the rewrite rules. Passing $this->rules instead of an empty string would prevent that.

Some of my websites had the permalinks broken after upgrading to 4.5.

Can you elaborate a bit? What exactly was broken? Was there any error message? Something in the log files? Can you reproduce it on another site without any plugins active?

#2 @fatorbinario
9 years ago

Sorry for that.

The permalinks return 404 if I set anything different than default (I normally use Name of the Post).
Any link besides Home, even pages like about and contact returns 404.

I tried flushing any cache and even disabled all plugins. The NginX directives are the same that I use on all my WP websites, the official one found on Codex.

Everything runs fine until I upgrade to 4.5 which comparing files today I figured changing that parameter made the URLs work again.

This bug seems to affect this theme but many others with different ones had no trouble.

#3 @dd32
9 years ago

I suspect this might be caused by an errant flush_rewrite_rules() being called on each page load, if the flush happens at the right time, it might prevent rewrite rules happening all together.

#4 @fatorbinario
9 years ago

Ok guys an important update on this ticket.

Another theme have the same bug "Axioma".

And to make the links work on both i had to replace the new update_option function with the old one before 4.5 which is delete_option. So this is how it should be on line 1813:

delete_option('rewrite_rules');
$this->wp_rewrite_rules();

Last edited 9 years ago by fatorbinario (previous) (diff)
Note: See TracTickets for help on using tickets.