File tree Expand file tree Collapse file tree 3 files changed +30
-20
lines changed Expand file tree Collapse file tree 3 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ PHP NEWS
17
17
- MBString:
18
18
. Fixed bug #78579 (mb_decode_numericentity: args number inconsistency).
19
19
(cmb)
20
+ . Fixed bug #78609 (mb_check_encoding() no longer supports stringable
21
+ objects). (cmb)
20
22
21
23
- Mysqlnd:
22
24
. Fixed bug #78525 (Memory leak in pdo when reusing native prepared
Original file line number Diff line number Diff line change @@ -4823,27 +4823,15 @@ PHP_FUNCTION(mb_check_encoding)
4823
4823
RETURN_FALSE ;
4824
4824
}
4825
4825
4826
- switch (Z_TYPE_P (input )) {
4827
- case IS_LONG :
4828
- case IS_DOUBLE :
4829
- case IS_NULL :
4830
- case IS_TRUE :
4831
- case IS_FALSE :
4832
- RETURN_TRUE ;
4833
- break ;
4834
- case IS_STRING :
4835
- if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
4836
- RETURN_FALSE ;
4837
- }
4838
- break ;
4839
- case IS_ARRAY :
4840
- if (!php_mb_check_encoding_recursive (HASH_OF (input ), enc )) {
4841
- RETURN_FALSE ;
4842
- }
4843
- break ;
4844
- default :
4845
- php_error_docref (NULL , E_WARNING , "Input is something other than scalar or array" );
4826
+ if (Z_TYPE_P (input ) == IS_ARRAY ) {
4827
+ if (!php_mb_check_encoding_recursive (HASH_OF (input ), enc )) {
4846
4828
RETURN_FALSE ;
4829
+ }
4830
+ } else {
4831
+ convert_to_string (input );
4832
+ if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
4833
+ RETURN_FALSE ;
4834
+ }
4847
4835
}
4848
4836
RETURN_TRUE ;
4849
4837
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #78609 (mb_check_encoding() no longer supports stringable objects)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ('mbstring ' )) die ('skip mbstring extension not available ' );
6
+ ?>
7
+ --FILE--
8
+ <?php
9
+ class Foo
10
+ {
11
+ public function __toString ()
12
+ {
13
+ return 'string_representation ' ;
14
+ }
15
+ }
16
+
17
+ var_dump (mb_check_encoding (new Foo , 'UTF-8 ' ));
18
+ ?>
19
+ --EXPECT--
20
+ bool(true)
You can’t perform that action at this time.
0 commit comments