safe-redirect-manager icon indicating copy to clipboard operation
safe-redirect-manager copied to clipboard

check_for_possible_redirect_loops runs in Theta( n^2 ) time

Open tlovett1 opened this issue 13 years ago • 5 comments

I was using this plugin on a project with ~250 redirects. I wrote an import script that made use of the create_redirect method to generate the redirects. After creating the redirects, the WordPress backend was "frozen". It seemed as though something was caught in an infinite loop.

After some searching I realized the problem was the check_for_possible_redirect_loops(). This method checks each redirect against every other redirect meaning it runs in Theta( n^2 ) time where n is the number of redirects. With 250 redirects, the contents of the loop in that function will be executed over 62,000 times.

Proposal: Add another filter "max_redirects_to_check_for_loops" or something to that effect. It should default to 50.

tlovett1 avatar Oct 10 '12 14:10 tlovett1

Is this project going to be dropping on VIP anytime soon? Seems like a pretty straightforward fix.

danielbachhuber avatar Oct 10 '12 16:10 danielbachhuber

Nope. Not a VIP project. I simply modified the plugin by removing the method call for the project.

tlovett1 avatar Oct 10 '12 18:10 tlovett1

Just pushed up a change that disables this by default and adds a filter to enable it.

tlovett1 avatar Oct 12 '12 19:10 tlovett1

@tlovett1 it's useful to map issues to milestones, and close them when they're fixed :)

danielbachhuber avatar Oct 18 '12 21:10 danielbachhuber

Ah ok. I'll try to do that.

tlovett1 avatar Oct 19 '12 13:10 tlovett1