Bug tracker

umil::get_table_names incorrectly handles certain table prefixes (fix completed in vcs)

There is a problem in umil::get_table_names method that causes table prefixes to be incorrectly replaced when the user-specified table prefix is a substring of the default one, 'phpbb_'. For example, using 'bb_' prefix causes the method to leave the table name intact:

$table_prefix = 'bb_';
$table_name = 'phpbb_automod';

$table_name = str_replace('phpbb_', $table_prefix,
str_replace($table_prefix, 'phpbb_', $table_name) // phpbb_automod => phpphpbb_automod
); // phpphpbb_automod => phpbb_automod

Comments / History

Changed ticket status from "New" to "Reviewed"

Action performed by EXreaction (Development Team Member) on Mar 10th 2010, 19:51

Assigned ticket to user "EXreaction"

Action performed by EXreaction (Development Team Member) on Mar 10th 2010, 19:52

Linked ticket with changeset: r201

Action performed by EXreaction (Development Team Member) on Mar 11th 2010, 01:59

Changed ticket status from "Reviewed" to "Fix completed in SVN"

Action performed by EXreaction (Development Team Member) on Mar 11th 2010, 02:00

Posted by EXreaction (Development Team Member) on Mar 11th 2010, 02:00

Fix completed in SVN.

Posted by EXreaction (Development Team Member) on Mar 11th 2010, 02:37

Also, it'll be a few weeks before a new package is able to be released, so I recommend you grab the umil.php file from SVN for your use.

Posted by actuator on Mar 11th 2010, 07:27

Ok, so the inner replace was useless after all. But should not the regex contain start-of-string marker, so it will match only the start of table name? There still could be problems if (unlikely) the table name itself contains 'phpbb_'.

Posted by EXreaction (Development Team Member) on Mar 11th 2010, 17:19

The double replace was to fix the issue with table prefixes like phpbb_1.

I do not think that would cause an issue, using the i argument in the regex it should only match it at the very beginning of the table name, but I'll test it soon to make sure.

Ticket details

Related SVN changesets