Skip to content

Commit 83e4365

Browse files
committed
Fix deprecated $php_errormsg in PHP 7.2
From the PHP 8.0 migration guide (https://www.php.net/manual/de/migration80.incompatible.php): The track_errors ini directive has been removed. This means that php_errormsg is no longer available. The error_get_last() function may be used instead. Also the documentation on $php_errormsg (https://www.php.net/manual/en/reserved.variables.phperrormsg.php) says: This feature has been DEPRECATED as of PHP 7.2.0. Relying on this feature is highly discouraged. Use error_get_last() instead. This commit breaks compatibility with PHP 5.6 Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
1 parent f64e368 commit 83e4365

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/Horde/String.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,9 @@ protected static function _convertCharset($input, $from, $to)
145145

146146
/* Try iconv with transliteration. */
147147
if (Horde_Util::extensionExists('iconv')) {
148-
unset($php_errormsg);
149-
ini_set('track_errors', 1);
148+
error_clear_last();
150149
$out = @iconv($from, $to . '//TRANSLIT', $input);
151-
$errmsg = isset($php_errormsg);
152-
ini_restore('track_errors');
153-
if (!$errmsg && $out !== false) {
150+
if (is_null(error_get_last()) && $out !== false) {
154151
return $out;
155152
}
156153
}
@@ -484,18 +481,15 @@ protected static function _pos(
484481
)
485482
{
486483
if (Horde_Util::extensionExists('mbstring')) {
487-
unset($php_errormsg);
488-
$track_errors = ini_set('track_errors', 1);
484+
error_clear_last();
489485
$ret = @call_user_func('mb_' . $func, $haystack, $needle, $offset, self::_mbstringCharset($charset));
490-
ini_set('track_errors', $track_errors);
491-
if (!isset($php_errormsg)) {
486+
if (is_null(error_get_last())) {
492487
return $ret;
493488
}
494489
}
495490

496491
if (Horde_Util::extensionExists('intl')) {
497-
unset($php_errormsg);
498-
$track_errors = ini_set('track_errors', 1);
492+
error_clear_last();
499493
$ret = self::convertCharset(
500494
@call_user_func(
501495
'grapheme_' . $func,
@@ -506,8 +500,7 @@ protected static function _pos(
506500
'UTF-8',
507501
$charset
508502
);
509-
ini_set('track_errors', $track_errors);
510-
if (!isset($php_errormsg)) {
503+
if (is_null(error_get_last())) {
511504
return $ret;
512505
}
513506
}

0 commit comments

Comments
 (0)