![]() |
small bug in _reindex_segments (Router.php) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: small bug in _reindex_segments (Router.php) (/showthread.php?tid=3014) |
small bug in _reindex_segments (Router.php) - El Forum - 09-05-2007 [eluser]El Oscuro[/eluser] Hello ~ I believe I discovered a small (but for me it was very tough to find) bug in CI. If we want to reroute something like http://myserver.com/blog/1 to http://myserver/blog/threads/1, it works fine. But if the rerouted URI only differs from the original one in the order of segments (example: http://myserver.com/blog/users/1 => http://myserver.com/users/blog/1), _reindex_segments function mistakenly assumes them identical and as a result, there's no rerouting at all. Here is the problem (Router.php, line 256): Code: // Is the routed segment array different then the main segment array? Code: if ($diff == FALSE) Quote:array_diff() returns an array containing all the values of array1 that are not present in any of the other arguments.This is not exactly what we want... The problem is that array_diff doesn't care about order (in other words, keys) of segments in arrays. I propose to use array_diff_assoc function here. I haven't tested it thoroughly but for now it works fine. Hope this will be useful for someone! :coolsmile: small bug in _reindex_segments (Router.php) - El Forum - 12-25-2007 [eluser]pjturpeau[/eluser] Is there a chance to get this bug fixed in the next CI release (1.5.5) ? It has also annoyed me for a while... thanks a lot. |