Make WordPress Core

Ticket #14889: chrisbliss18-patch.diff

File chrisbliss18-patch.diff, 1.2 KB (added by chrisbliss18, 16 years ago)
  • wp-includes/default-constants.php

    diff --git wp-includes/default-constants.php wp-includes/default-constants.php
    index 47b9cd7..2774615 100644
    function wp_initial_constants( ) {  
    3535                $blog_id = 1;
    3636
    3737        // set memory limits.
    38         if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
    39                 @ini_set('memory_limit', WP_MEMORY_LIMIT);
     38        if ( function_exists( 'memory_get_usage' ) ) {
     39                $memory_limit = @ini_get( 'memory_limit' );
     40                switch( substr( $memory_limit, -1 ) ) {
     41                        case 'M': case 'm':
     42                                $memory_limit = (int) $memory_limit;
     43                                break;
     44                        case 'G': case 'g':
     45                                $memory_limit = (int) $memory_limit * 1024;
     46                                break;
     47                        case 'K': case 'k':
     48                                $memory_limit = (int) $memory_limit / 1024;
     49                                break;
     50                        default:
     51                                $memory_limit = (int) $memory_limit / 1048576;
     52                }
     53
     54                if ( $memory_limit < abs( intval( WP_MEMORY_LIMIT ) ) )
     55                        @ini_set( 'memory_limit', WP_MEMORY_LIMIT );
     56        }
    4057
    4158        if ( !defined('WP_CONTENT_DIR') )
    4259                define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down