View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0030429 | mantisbt | other | public | 2022-05-31 19:15 | 2023-02-22 19:21 |
Reporter | ChrisG | Assigned To | dregad | ||
Priority | high | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Target Version | 2.25.6 | Fixed in Version | 2.25.6 | ||
Summary | 0030429: Upcoming incompatibility with PHP 8.2, "Deprecate ${} string interpolation" RFC | ||||
Description | The "Deprecate ${} string interpolation" RFC (https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation) has been passed. The Mantis code is using what is deprecated in a few places at the moment. | ||||
Additional Information | I've attached the changes I think would be needed based on my copy of 2.24.0. I don't have the time to contribute a proper pull request at the moment I'm afraid. | ||||
Tags | PHP 8.2 | ||||
Attached Files | deprecate_dollar_brace_string_interpolation.diff (4,295 bytes)
diff --git a/tracker/core/file_api.php b/core/file_api.php index 06ebc5a1a4..2e663534d5 100644 --- a/core/file_api.php +++ b/core/file_api.php @@ -710,7 +710,7 @@ function diskfile_is_name_unique( $p_name, $p_filepath ) { * @return boolean true if unique */ function file_is_name_unique( $p_name, $p_bug_id, $p_table = 'bug' ) { - $t_file_table = db_get_table( "${p_table}_file" ); + $t_file_table = db_get_table( "{$p_table}_file" ); db_param_push(); $t_query = 'SELECT COUNT(*) FROM ' . $t_file_table . ' WHERE filename=' . db_param(); diff --git a/core/plugin_api.php b/core/plugin_api.php index eda53f62ff..8b85e134c7 100644 --- a/core/plugin_api.php +++ b/core/plugin_api.php @@ -420,7 +420,7 @@ function plugin_error( $p_error_name, $p_error_type = ERROR, $p_basename = null $t_basename = $p_basename; } - $t_error_code = "plugin_${t_basename}_${p_error_name}"; + $t_error_code = "plugin_{$t_basename}_{$p_error_name}"; trigger_error( $t_error_code, $p_error_type ); } @@ -1030,7 +1030,7 @@ function plugin_init( $p_basename ) { $t_plugin_errors = $t_plugin->errors(); foreach( $t_plugin_errors as $t_error_name => $t_error_string ) { - $t_error_code = "plugin_${p_basename}_${t_error_name}"; + $t_error_code = "plugin_{$p_basename}_{$t_error_name}"; $g_lang_strings[$t_lang]['MANTIS_ERROR'][$t_error_code] = $t_error_string; } diff --git a/core/string_api.php b/core/string_api.php index e14a652d4c..f0da6db6c8 100644 --- a/core/string_api.php +++ b/core/string_api.php @@ -492,15 +492,15 @@ function string_insert_hrefs( $p_string ) { # valid set of characters that may occur in url scheme. Note: - should be first (A-F != -AF). $t_url_valid_chars = '-_.,!~*\';\/?%^\\\\:@&={\|}+$#[:alnum:]\pL'; - $t_url_chars = "(?:${t_url_hex}|[${t_url_valid_chars}\(\)\[\]])"; - $t_url_chars2 = "(?:${t_url_hex}|[${t_url_valid_chars}])"; - $t_url_chars_in_brackets = "(?:${t_url_hex}|[${t_url_valid_chars}\(\)])"; - $t_url_chars_in_parens = "(?:${t_url_hex}|[${t_url_valid_chars}\[\]])"; + $t_url_chars = "(?:{$t_url_hex}|[{$t_url_valid_chars}\(\)\[\]])"; + $t_url_chars2 = "(?:{$t_url_hex}|[{$t_url_valid_chars}])"; + $t_url_chars_in_brackets = "(?:{$t_url_hex}|[{$t_url_valid_chars}\(\)])"; + $t_url_chars_in_parens = "(?:{$t_url_hex}|[{$t_url_valid_chars}\[\]])"; $t_url_part1 = $t_url_chars; - $t_url_part2 = "(?:\(${t_url_chars_in_parens}*\)|\[${t_url_chars_in_brackets}*\]|${t_url_chars2})"; + $t_url_part2 = "(?:\({$t_url_chars_in_parens}*\)|\[{$t_url_chars_in_brackets}*\]|{$t_url_chars2})"; - $s_url_regex = "/(${t_url_protocol}(${t_url_part1}*?${t_url_part2}+))/su"; + $s_url_regex = "/({$t_url_protocol}({$t_url_part1}*?{$t_url_part2}+))/su"; # e-mail regex $s_email_regex = substr_replace( email_regex_simple(), '(?:mailto:)?', 1, 0 ); @@ -516,7 +516,7 @@ function string_insert_hrefs( $p_string ) { } else { $t_url_target = ''; } - return "<a ${t_url_href}${t_url_target}>${p_match[1]}</a>"; + return "<a {$t_url_href}{$t_url_target}>{$p_match[1]}</a>"; }, $p_string ); diff --git a/login_page.php b/login_page.php index 69830ba051..a08f7619a8 100644 --- a/login_page.php +++ b/login_page.php @@ -165,7 +165,7 @@ if( config_get_global( 'admin_checks' ) == ON ) { function debug_setting_message ( $p_type, $p_setting, $p_value ) { return sprintf( lang_get( 'warning_change_setting' ), $p_setting, $p_value ) . sprintf( lang_get( 'word_separator' ) ) - . sprintf( lang_get( "warning_${p_type}_hazard" ) ); + . sprintf( lang_get( "warning_{$p_type}_hazard" ) ); } $t_config = 'show_detailed_errors'; | ||||
@ChrisG as a side note, I expect you will encounter some more issues when using PHP 8.2 to run MantisBT 2.24.0. |
|
Thanks. I have a fork of Mantis in a big monolithic repository I maintain, and regularly scan the whole repository for forthcoming compat issues where possible. So this is more me sharing my findings, not me wanting to actually stick to that particular older version. |
|
Thanks for the patch @ChrisG, I actually had this on my to-do list. As a side note, it would have been even nicer if you had not switched indents from tabs to spaces, as I could not apply it automatically. Since it was only minor changes to a just a few lines, it's no big deal, but if you could please keep that in mind for future contributions it would be great. |
|
@dregad a grep on my sources shows some more of the 1) |
|
@dregad I think that whitespace borking came from me copy & pasting from a "git diff" on the terminal. Will bear in mind in the future. Ideally I'd put through a proper pull request, just I've got a baby at the moment sucking on a lot of things including my time. |
|
@obmsch thanks for the feedback
I did notice these, but they do not need to be touched because it's the Variable variables outside of strings case, which is unchanged by the RFC
Thanks for the heads up on these, I'll take care of them. Anyway as you said there is no rush, since PHP 8.2 is only due in November. No worries, and congratulations :-) I can live without a PR, but what you could easily do with very little overhead is, instead of copy/paste: |
|
Source integration plugin fixed: https://github.com/mantisbt-plugins/source-integration/issues/396 |
|
The 3 occurrences are also of the Variable variables outside of strings sort, so no changes are needed on the ADOdb side. |
|
Changing target to 2.25.6, as I've hit a conflict resolution when merging another issue and we might as well have PHP 8.2 compatibility in 2.25 branch. |
|
MantisBT: master c3cbfe2c 2022-06-02 05:31 Details Diff |
Fix deprecated usage of ${} string interpolation The "Deprecate ${} string interpolation" RFC [1] has been acceoted and will be implemented in PHP 8.2. The Mantis code was using the deprecated syntax in a few places, this fixes these occurrences. Thanks to ChrisG for the original patch. Fixes 0030429 [1]: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation |
Affected Issues 0030429 |
|
mod - core/file_api.php | Diff File | ||
mod - core/plugin_api.php | Diff File | ||
mod - core/string_api.php | Diff File | ||
mod - login_page.php | Diff File | ||
MantisBT: master-2.25 3b2ec19e 2022-06-02 05:31 Details Diff |
Fix deprecated usage of ${} string interpolation The "Deprecate ${} string interpolation" RFC [1] has been acceoted and will be implemented in PHP 8.2. The Mantis code was using the deprecated syntax in a few places, this fixes these occurrences. Thanks to ChrisG for the original patch. Fixes 0030429 [1]: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation (cherry picked from commit c3cbfe2c90240d15bf0e450254cbeb68050655ba) # Conflicts: # core/string_api.php |
Affected Issues 0030429 |
|
mod - core/file_api.php | Diff File | ||
mod - core/plugin_api.php | Diff File | ||
mod - core/string_api.php | Diff File | ||
mod - login_page.php | Diff File |