diff --git src/wp-admin/admin.php src/wp-admin/admin.php
index 184d5c2..8dd251f 100644
|
|
else |
138 | 138 | require(ABSPATH . 'wp-admin/menu.php'); |
139 | 139 | |
140 | 140 | if ( current_user_can( 'manage_options' ) ) { |
141 | | /** |
142 | | * Filter the maximum memory limit available for administration screens. |
143 | | * |
144 | | * This only applies to administrators, who may require more memory for tasks like updates. |
145 | | * Memory limits when processing images (uploaded or edited by users of any role) are |
146 | | * handled separately. |
147 | | * |
148 | | * The WP_MAX_MEMORY_LIMIT constant specifically defines the maximum memory limit available |
149 | | * when in the administration back-end. The default is 256M, or 256 megabytes of memory. |
150 | | * |
151 | | * @since 3.0.0 |
152 | | * |
153 | | * @param string 'WP_MAX_MEMORY_LIMIT' The maximum WordPress memory limit. Default 256M. |
154 | | */ |
155 | | @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
| 141 | wp_raise_memory_limit( 'admin_memory_limit' ); |
156 | 142 | } |
157 | 143 | |
158 | 144 | /** |
diff --git src/wp-admin/includes/file.php src/wp-admin/includes/file.php
index 3b4d1c6..036c039 100644
|
|
function unzip_file($file, $to) { |
546 | 546 | return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
547 | 547 | |
548 | 548 | // Unzip can use a lot of memory, but not this much hopefully |
549 | | /** This filter is documented in wp-admin/admin.php */ |
550 | | @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
| 549 | wp_raise_memory_limit( 'admin_memory_limit' ); |
551 | 550 | |
552 | 551 | $needed_dirs = array(); |
553 | 552 | $to = trailingslashit($to); |
diff --git src/wp-admin/includes/image-edit.php src/wp-admin/includes/image-edit.php
index 4015f30..38fa83e 100644
|
|
function image_edit_apply_changes( $image, $changes ) { |
557 | 557 | function stream_preview_image( $post_id ) { |
558 | 558 | $post = get_post( $post_id ); |
559 | 559 | |
560 | | /** This filter is documented in wp-admin/admin.php */ |
561 | | @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
| 560 | wp_raise_memory_limit( 'admin_memory_limit' ); |
562 | 561 | |
563 | 562 | $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) ); |
564 | 563 | |
diff --git src/wp-includes/class-wp-image-editor-gd.php src/wp-includes/class-wp-image-editor-gd.php
index 2093c6b..81fcd90 100644
|
|
class WP_Image_Editor_GD extends WP_Image_Editor { |
96 | 96 | if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) |
97 | 97 | return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); |
98 | 98 | |
99 | | /** |
100 | | * Filter the memory limit allocated for image manipulation. |
101 | | * |
102 | | * @since 3.5.0 |
103 | | * |
104 | | * @param int|string $limit Maximum memory limit to allocate for images. Default WP_MAX_MEMORY_LIMIT. |
105 | | * Accepts an integer (bytes), or a shorthand string notation, such as '256M'. |
106 | | */ |
107 | | // Set artificially high because GD uses uncompressed images in memory |
108 | | @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
| 99 | wp_raise_memory_limit( 'image_memory_limit' ); |
109 | 100 | |
110 | 101 | $this->image = @imagecreatefromstring( file_get_contents( $this->file ) ); |
111 | 102 | |
diff --git src/wp-includes/class-wp-image-editor-imagick.php src/wp-includes/class-wp-image-editor-imagick.php
index a14fa40..27117d9 100644
|
|
class WP_Image_Editor_Imagick extends WP_Image_Editor { |
129 | 129 | if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) ) |
130 | 130 | return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file ); |
131 | 131 | |
132 | | /** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */ |
133 | 132 | // Even though Imagick uses less PHP memory than GD, set higher limit for users that have low PHP.ini limits |
134 | | @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
| 133 | wp_raise_memory_limit( 'image_memory_limit' ); |
135 | 134 | |
136 | 135 | try { |
137 | 136 | $this->image = new Imagick( $this->file ); |
diff --git src/wp-includes/default-constants.php src/wp-includes/default-constants.php
index c9092bd..df004ec 100644
|
|
function wp_initial_constants() { |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
| 29 | $current_limit = @ini_get( 'memory_limit' ); |
| 30 | $current_limit_int = intval( $current_limit ); |
| 31 | |
29 | 32 | if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) { |
30 | | define( 'WP_MAX_MEMORY_LIMIT', '256M' ); |
| 33 | if ( -1 === $current_limit_int || $current_limit_int > 256 ) { |
| 34 | define( 'WP_MAX_MEMORY_LIMIT', $current_limit ); |
| 35 | } else { |
| 36 | define( 'WP_MAX_MEMORY_LIMIT', '256M' ); |
| 37 | } |
31 | 38 | } |
32 | 39 | |
33 | 40 | if ( ! isset($blog_id) ) |
… |
… |
function wp_initial_constants() { |
35 | 42 | |
36 | 43 | // set memory limits. |
37 | 44 | if ( function_exists( 'memory_get_usage' ) ) { |
38 | | $current_limit = @ini_get( 'memory_limit' ); |
39 | | $current_limit_int = intval( $current_limit ); |
40 | 45 | if ( false !== strpos( $current_limit, 'G' ) ) |
41 | 46 | $current_limit_int *= 1024; |
42 | 47 | $wp_limit_int = intval( WP_MEMORY_LIMIT ); |
diff --git src/wp-includes/deprecated.php src/wp-includes/deprecated.php
index 91a1543..b50094b 100644
|
|
function wp_load_image( $file ) { |
3134 | 3134 | return __('The GD image library is not installed.'); |
3135 | 3135 | |
3136 | 3136 | // Set artificially high because GD uses uncompressed images in memory |
3137 | | @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
| 3137 | wp_raise_memory_limit( 'image_memory_limit' ); |
3138 | 3138 | $image = imagecreatefromstring( file_get_contents( $file ) ); |
3139 | 3139 | |
3140 | 3140 | if ( !is_resource( $image ) ) |
diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index e3fb353..5d02471 100644
|
|
function mysql_to_rfc3339( $date_string ) { |
5166 | 5166 | // Strip timezone information |
5167 | 5167 | return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted ); |
5168 | 5168 | } |
| 5169 | |
| 5170 | /** |
| 5171 | * WP raise memory limit |
| 5172 | * |
| 5173 | * Raises the default memory limit for memory intensive processes. |
| 5174 | * Only allow filter to raise and not lower the limit. |
| 5175 | * |
| 5176 | * @param string $filter Filter name |
| 5177 | */ |
| 5178 | function wp_raise_memory_limit( $filter ) { |
| 5179 | $current_limit = WP_MAX_MEMORY_LIMIT; |
| 5180 | $current_limit_int = intval( $current_limit ); |
| 5181 | $new_limit = apply_filters( $filter, $current_limit ); |
| 5182 | $new_limit_int = intval( $new_limit ); |
| 5183 | |
| 5184 | if ( -1 === $new_limit_int || $new_limit_int > $current_limit_int ) { |
| 5185 | @ini_set( 'memory_limit', $new_limit ); |
| 5186 | } else { |
| 5187 | @ini_set( 'memory_limit', $current_limit ); |
| 5188 | } |
| 5189 | } |