Skip to content

Commit efc8f0e

Browse files
arnaud-lbsgolemon
andauthored
Deprecate zend_atol() / add zend_ini_parse_quantity() (#7951)
Add zend_ini_parse_quantity() and deprecate zend_atol(), zend_atoi() zend_atol() and zend_atoi() don't just do number parsing. They also check for a 'K', 'M', or 'G' at the end of the string, and multiply the parsed value out accordingly. Unfortunately, they ignore any other non-numerics between the numeric component and the last character in the string. This means that numbers such as the following are both valid and non-intuitive in their final output. * "123KMG" is interpreted as "123G" -> 132070244352 * "123G " is interpreted as "123 " -> 123 * "123GB" is interpreted as "123B" -> 123 * "123 I like tacos." is also interpreted as "123." -> 123 Currently, in php-src these functions are used only for parsing ini values. In this change we deprecate zend_atol(), zend_atoi(), and introduce a new function with the same behavior, but with the ability to report invalid inputs to the caller. The function's name also makes the behavior less unexpected: zend_ini_parse_quantity(). Co-authored-by: Sara Golemon <[email protected]>
1 parent 9458f5f commit efc8f0e

25 files changed

+1666
-22
lines changed

UPGRADING

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,91 @@ PHP 8.2 UPGRADE NOTES
342342
11. Changes to INI File Handling
343343
========================================
344344

345+
- Parsing of some ill-formatted values will now trigger a warning when this was
346+
silently ignored before. Interpretation of these values is not changed, for
347+
backwards compatibility. This affects the following settings:
348+
. bcmath.scale
349+
. com.code_page
350+
. default_socket_timeout
351+
. fiber.stack_size
352+
. hard_timeout
353+
. intl.error_level
354+
. ldap.max_links
355+
. max_input_nesting_level
356+
. max_input_vars
357+
. mbstring.regex_retry_limit
358+
. mbstring.regex_stack_limit
359+
. mysqli.allow_local_infile
360+
. mysqli.allow_persistent
361+
. mysqli.default_port
362+
. mysqli.max_links
363+
. mysqli.max_persistent
364+
. mysqli.reconnect
365+
. mysqli.rollback_on_cached_plink
366+
. mysqlnd.log_mask
367+
. mysqlnd.mempool_default_size
368+
. mysqlnd.net_read_buffer_size
369+
. mysqlnd.net_read_timeout
370+
. oci8.default_prefetch
371+
. oci8.max_persistent
372+
. oci8.persistent_timeout
373+
. oci8.ping_interval
374+
. oci8.prefetch_lob_size
375+
. oci8.privileged_connect
376+
. oci8.statement_cache_size
377+
. odbc.allow_persistent
378+
. odbc.check_persistent
379+
. odbc.defaultbinmode
380+
. odbc.default_cursortype
381+
. odbc.defaultlrl
382+
. odbc.max_links
383+
. odbc.max_persistent
384+
. opcache.consistency_checks
385+
. opcache.file_update_protection
386+
. opcache.force_restart_timeout
387+
. opcache.interned_strings_buffer
388+
. opcache.jit_bisect_limit
389+
. opcache.jit_blacklist_root_trace
390+
. opcache.jit_blacklist_side_trace
391+
. opcache.jit_debug
392+
. opcache.jit_hot_func
393+
. opcache.jit_hot_loop
394+
. opcache.jit_hot_return
395+
. opcache.jit_hot_side_exit
396+
. opcache.jit_max_exit_counters
397+
. opcache.jit_max_loop_unrolls
398+
. opcache.jit_max_polymorphic_calls
399+
. opcache.jit_max_recursive_calls
400+
. opcache.jit_max_recursive_returns
401+
. opcache.jit_max_root_traces
402+
. opcache.jit_max_side_traces
403+
. opcache.log_verbosity_level
404+
. opcache.max_file_size
405+
. opcache.opt_debug_level
406+
. opcache.optimization_level
407+
. opcache.revalidate_freq
408+
. output_buffering
409+
. pcre.backtrack_limit
410+
. pcre.recursion_limit
411+
. pgsql.max_links
412+
. pgsql.max_persistent
413+
. post_max_size
414+
. realpath_cache_size
415+
. realpath_cache_ttl
416+
. session.cache_expire
417+
. session.cookie_lifetime
418+
. session.gc_divisor
419+
. session.gc_maxlifetime
420+
. session.gc_probability
421+
. soap.wsdl_cache_limit
422+
. soap.wsdl_cache_ttl
423+
. unserialize_max_depth
424+
. upload_max_filesize
425+
. user_ini.cache_ttl
426+
. xmlrpc_error_number
427+
. zend.assertions
428+
. zlib.output_compression_level
429+
345430
========================================
346431
12. Windows Support
347432
========================================

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ PHP 8.2 INTERNALS UPGRADE NOTES
2929
* A new ZEND_THREEWAY_COMPARE() macro has been introduced which does a
3030
three-way comparison of two integers and returns -1, 0 or 1 if the LHS is
3131
smaller, equal or larger than the RHS
32+
* Deprecated zend_atoi() and zend_atol(). Use ZEND_STRTOL() for general purpose
33+
string to long conversion, or a variant of zend_ini_parse_quantity() for
34+
parsing ini quantities.
3235

3336
========================
3437
2. Build system changes

0 commit comments

Comments
 (0)