1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

mbstring: fix missing copying of detect_order_list to current_detect_order_list on ini_set('mbstring.detect_order', string)

Closes GH-20523.
This commit is contained in:
Tobias Vorwachs
2025-11-18 17:15:06 +01:00
committed by Alex Dowad
parent 1848bcddfd
commit 6b197ee4ed
4 changed files with 81 additions and 0 deletions

4
NEWS
View File

@@ -20,6 +20,10 @@ PHP NEWS
. Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI
small value). (David Carlier)
- Mbstring:
. ini_set() with mbstring.detect_order changes the order of mb_detect_order
as intended, since mbstring.detect_order is an INI_ALL setting. (tobee94)
- Opcache:
. Fixed bug GH-20051 (apache2 shutdowns when restart is requested during
preloading). (Arnaud, welcomycozyhom)

View File

@@ -98,6 +98,13 @@ PHP 8.6 UPGRADE NOTES
When used along with ZEND_JIT_DEBUG_TRACE_EXIT_INFO, the source of exit
points is printed in exit info output, in debug builds.
- Mbstring:
. The mbstring.detect_order INI directive now updates the internal detection
order when changed at runtime via ini_set(). Previously, runtime changes
using ini_set() did not take effect for mb_detect_order(). Setting the
directive to NULL or an empty string at runtime now leaves the previously
configured detection order unchanged.
========================================
12. Windows Support
========================================

View File

@@ -718,6 +718,11 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order)
}
MBSTRG(detect_order_list) = list;
MBSTRG(detect_order_list_size) = size;
if (stage == PHP_INI_STAGE_RUNTIME) {
php_mb_populate_current_detect_order_list();
}
return SUCCESS;
}
/* }}} */
@@ -5981,6 +5986,11 @@ static void php_mb_populate_current_detect_order_list(void)
entry[i] = mbfl_no2encoding(src[i]);
}
}
if (MBSTRG(current_detect_order_list) != NULL) {
efree(ZEND_VOIDP(MBSTRG(current_detect_order_list)));
}
MBSTRG(current_detect_order_list) = entry;
MBSTRG(current_detect_order_list_size) = nentries;
}

View File

@@ -0,0 +1,60 @@
--TEST--
Test mb_detect_order() function : ini set changes order
--EXTENSIONS--
mbstring
--INI--
mbstring.detect_order=UTF-8,ISO-8859-15,ISO-8859-1,ASCII
--FILE--
<?php
var_dump( mb_detect_order());
ini_set('mbstring.detect_order', 'UTF-8, ISO-8859-1, ASCII');
var_dump( mb_detect_order());
ini_set('mbstring.detect_order', 'UTF-8');
var_dump( mb_detect_order());
ini_set('mbstring.detect_order', NULL);
var_dump( mb_detect_order());
ini_set('mbstring.detect_order', '');
var_dump( mb_detect_order());
?>
--EXPECT--
array(4) {
[0]=>
string(5) "UTF-8"
[1]=>
string(11) "ISO-8859-15"
[2]=>
string(10) "ISO-8859-1"
[3]=>
string(5) "ASCII"
}
array(3) {
[0]=>
string(5) "UTF-8"
[1]=>
string(10) "ISO-8859-1"
[2]=>
string(5) "ASCII"
}
array(1) {
[0]=>
string(5) "UTF-8"
}
array(1) {
[0]=>
string(5) "UTF-8"
}
array(1) {
[0]=>
string(5) "UTF-8"
}