Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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
========================================
Expand Down
10 changes: 10 additions & 0 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
/* }}} */
Expand Down Expand Up @@ -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;
}
Expand Down
60 changes: 60 additions & 0 deletions ext/mbstring/tests/mb_detect_order_with_ini_set.phpt
Original file line number Diff line number Diff line change
@@ -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"
}

Loading