Skip to content

Commit

Permalink
Various fixes to backward compatibility support
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Nov 27, 2023
1 parent beb39bc commit 8b581f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
5 changes: 3 additions & 2 deletions Sources/QueryString.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ class QueryString
* BackwardCompatibility settings for this class.
*/
private static $backcompat = [
// Public static methods not listed here will keep the same name when
// exported to global namespace.
'func_names' => [
'cleanRequest' => 'cleanRequest',
'isFilteredRequest' => 'is_filtered_request',
'ob_sessrewrite' => 'ob_sessrewrite',
'matchIPtoCIDR' => 'matchIPtoCIDR',
],
];

Expand Down
52 changes: 24 additions & 28 deletions Sources/Subs-Compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

/**
* This file provides compatibility functions and code for older versions of
* PHP, such as the sha1() function, missing extensions, or 64-bit vs 32-bit
* systems. It is only included for those older versions or when the respective
* extension or function cannot be found.
* SMF and PHP, such as missing extensions or 64-bit vs 32-bit systems.
*
* Simple Machines Forum (SMF)
*
Expand Down Expand Up @@ -118,31 +116,31 @@ function smf_crc32($number)
* Polyfills, etc.
*****************/

// This is wrapped in a closure to keep the global namespace clean.
call_user_func(function () {
/**
* IDNA_* constants used as flags for the idn_to_* functions.
*/
$idna_constants = [
'IDNA_DEFAULT' => 0,
'IDNA_ALLOW_UNASSIGNED' => 1,
'IDNA_USE_STD3_RULES' => 2,
'IDNA_CHECK_BIDI' => 4,
'IDNA_CHECK_CONTEXTJ' => 8,
'IDNA_NONTRANSITIONAL_TO_ASCII' => 16,
'IDNA_NONTRANSITIONAL_TO_UNICODE' => 32,
'INTL_IDNA_VARIANT_2003' => 0,
'INTL_IDNA_VARIANT_UTS46' => 1,
];

foreach ($idna_constants as $name => $value) {
if (!defined($name)) {
define($name, $value);
if (!function_exists('idn_to_ascii')) {
// This is wrapped in a closure to keep the global namespace clean.
call_user_func(function () {
/**
* IDNA_* constants used as flags for the idn_to_* functions.
*/
$idna_constants = [
'IDNA_DEFAULT' => 0,
'IDNA_ALLOW_UNASSIGNED' => 1,
'IDNA_USE_STD3_RULES' => 2,
'IDNA_CHECK_BIDI' => 4,
'IDNA_CHECK_CONTEXTJ' => 8,
'IDNA_NONTRANSITIONAL_TO_ASCII' => 16,
'IDNA_NONTRANSITIONAL_TO_UNICODE' => 32,
'INTL_IDNA_VARIANT_2003' => 0,
'INTL_IDNA_VARIANT_UTS46' => 1,
];

foreach ($idna_constants as $name => $value) {
if (!defined($name)) {
define($name, $value);
}
}
}
});
});

if (!function_exists('idn_to_ascii')) {
/**
* Compatibility function.
*
Expand Down Expand Up @@ -177,9 +175,7 @@ function idn_to_ascii($domain, $flags = 0, $variant = 1, &$idna_info = null)

return $Punycode->encode($domain);
}
}

if (!function_exists('idn_to_utf8')) {
/**
* Compatibility function.
*
Expand Down

0 comments on commit 8b581f3

Please sign in to comment.