View Issue Details

IDProjectCategoryView StatusLast Update
0016038mantisbtbugtrackerpublic2017-05-15 04:43
Reporterdregad Assigned Todregad  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version1.3.0dev 
Target Version1.3.0-beta.1 
Summary0016038: Make db_get_table() backwards-compatible with 1.2.
Description

0010914 changed the way db_get_table() generates the physical table name, as well as the function's input parameter ('tablename' vs 'mantis_tablename_table'). This change broke the API, and forces all plugins to be adapted.

In order to minimize the impact on plugin maintainers, the function should accept both the old and the new style parameter.

TagsNo tags attached.

Relationships

child of 0010914 closeddhx Make db_get_table behave like plugin_table 

Activities

There are no notes attached to this issue.

Related Changesets

MantisBT: master 295bdc9e

2013-06-09 13:57

Damien Regad


Details Diff
Make db_get_table() backwards-compatible with 1.2

Issue 0010914 changed the way db_get_table() generates the physical
table name, as well as the function's input parameter ('TABLENAME' vs
'mantis_TABLENAME_table'). This change broke the API, forcing all
plugins to be adapted.

In order to minimize the impact on plugin maintainers, the function
now accepts both the old and the new style parameter.

Fixes 0016038
Affected Issues
0016038
mod - core/database_api.php Diff File

MantisBT: master dadba42f

2013-06-09 16:06

Damien Regad


Details Diff
Trigger warning when using old-style db_get_table()

Follow-up commit on fix to issue 0016038, a warning is triggered to
inform user that deprecated functionality is being used, encouraging
plugin developers to update their code.
Affected Issues
0016038
mod - core/constant_inc.php Diff File
mod - core/database_api.php Diff File
mod - lang/strings_english.txt Diff File

MantisBT: master 38bc0248

2013-06-10 06:56

Damien Regad


Details Diff
Issue 0016038: improve performance

Use strpos+substr instead of preg_match.
Affected Issues
0016038
mod - core/database_api.php Diff File

MantisBT: master 4917320b

2017-04-12 04:29

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
Affected Issues
0016038, 0020168
mod - core/database_api.php Diff File

MantisBT: master-1.3.x b933abcb

2017-04-12 04:29

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.
Affected Issues
0016038, 0020168
mod - core/database_api.php Diff File