Search Changesets

MantisBT: master-1.3.x b933abcb

2017-04-12 08:29:01

dregad

Details Diff
db_get_table() also check suffix for legacy-style names

If $db_table_plugin_prefix contains 'mantis', db_get_table() function
will incorrectly process a plugin's tables as if they were legacy tables
(i.e. 'Mantis 1.2 style', with a 'mantis_' prefix).

If $db_table_suffix also is not set to '_table', then the generated table
name will be incorrect (e.g. with the Source Integration plugin,
changeset table will be generated as 'mantis_Source_ch_suffix' instead
of 'mantis_mantis_Source_changeset_suffix'), causing the installation by
plugin_upgrade() to fail and invalid tables to be created.

We now use a regex to check for legacy tables, verifying that it ends
with '_table' in addition to beginning with 'mantis_'. This basically
reverts commit 38bc02483eb58a3708e4f419bfa7c02b6c6900db (issue 0016038).

Note on performance: while preg_match() is slower than strpos(), it is
actually more efficient to use that, considering that we would need a
second function call to check for the suffix, as well as a substr() call
to extract the table name, while preg_match() does it all at once.

Fixes 0020168

Backported from master 4917320b2067f5797aa87e5772a820e6b5a177cc.
mod - core/database_api.php Diff File