MantisBT: master 4917320b

Author Committer Branch Timestamp Parent
dregad dregad master 2017-04-12 04:29 master 06e76774
Affected Issues  0016038: Make db_get_table() backwards-compatible with 1.2.
 0020168: Use of 'mantis' as plugin table prefix prevents plugin's installation
Changeset

db_get_table() also check suffix for legacy-style names

If $db_table_plugin_prefix contains 'mantis', db_gettable() 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

mod - core/database_api.php Diff File