Make WordPress Core


Ignore:
Timestamp:
07/08/2016 02:36:37 PM (9 years ago)
Author:
ocean90
Message:

Bootstrap: Enhance core's memory limit handling.

  • Don't lower memory limit if the current limit is greater than WP_MAX_MEMORY_LIMIT.
  • Set WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT to current limit if the memory_limit setting can't be changed at runtime.
  • Use wp_convert_hr_to_bytes() when parsing the value of the memory_limit setting because it can be a shorthand or an integer value.
  • Introduce wp_raise_memory_limit( $context ) to raise the PHP memory limit for memory intensive processes. This DRYs up some logic and includes the existing admin_memory_limit and image_memory_limit filters. The function can also be used for custom contexts, the {$context}_memory_limit filter allows to customize the limit.
  • Introduce wp_is_ini_value_changeable( $setting ) to determine whether a PHP ini value is changeable at runtime.
  • Remove a function_exists( 'memory_get_usage' ) check. Since PHP 5.2.1 support for memory limit is always enabled.

Related commits: [38011-38013]

Props jrf, A5hleyRich, swissspidy, ocean90.
Fixes #32075.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/load.php

    r38013 r38015  
    10031003    return min( $bytes, PHP_INT_MAX );
    10041004}
     1005
     1006/**
     1007 * Determines whether a PHP ini value is changeable at runtime.
     1008 *
     1009 * @since 4.6.0
     1010 *
     1011 * @link http://php.net/manual/en/function.ini-get-all.php
     1012 *
     1013 * @param string $setting The name of the ini setting to check.
     1014 * @return bool True if the value is changeable at runtime. False otherwise.
     1015 */
     1016function wp_is_ini_value_changeable( $setting ) {
     1017    static $ini_all;
     1018
     1019    if ( ! isset( $ini_all ) ) {
     1020        $ini_all = ini_get_all();
     1021    }
     1022
     1023    if ( isset( $ini_all[ $setting ]['access'] ) && ( INI_ALL === $ini_all[ $setting ]['access'] || INI_USER === $ini_all[ $setting ]['access'] ) ) {
     1024        return true;
     1025    }
     1026
     1027    return false;
     1028}
Note: See TracChangeset for help on using the changeset viewer.