<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[17749] trunk:
  Introduce WP_MAX_MEMORY_LIMIT constant for the high memory limit we set when image processing and unzipping
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17749">17749</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2011-04-28 16:25:36 +0000 (Thu, 28 Apr 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Introduce WP_MAX_MEMORY_LIMIT constant for the high memory limit we set when image processing and unzipping.
Ensure it is always filterable by plugins as well as configurable in wp-config
Fixes <a href="http://trac.wordpress.org/ticket/13847">#13847</a> props hakre</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminadminphp">trunk/wp-admin/admin.php</a></li>
<li><a href="#trunkwpadminincludesfilephp">trunk/wp-admin/includes/file.php</a></li>
<li><a href="#trunkwpadminincludesimageeditphp">trunk/wp-admin/includes/image-edit.php</a></li>
<li><a href="#trunkwpincludesdefaultconstantsphp">trunk/wp-includes/default-constants.php</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
<li><a href="#trunkwpsettingsphp">trunk/wp-settings.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminadminphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/admin.php (17748 => 17749)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/admin.php        2011-04-28 15:24:49 UTC (rev 17748)
+++ trunk/wp-admin/admin.php        2011-04-28 16:25:36 UTC (rev 17749)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">         require(ABSPATH . 'wp-admin/menu.php');
</span><span class="cx"> 
</span><span class="cx"> if ( current_user_can( 'manage_options' ) )
</span><del>-        @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );
</del><ins>+        @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
</ins><span class="cx"> 
</span><span class="cx"> do_action('admin_init');
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludesfilephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/file.php (17748 => 17749)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/file.php        2011-04-28 15:24:49 UTC (rev 17748)
+++ trunk/wp-admin/includes/file.php        2011-04-28 16:25:36 UTC (rev 17749)
</span><span class="lines">@@ -518,7 +518,7 @@
</span><span class="cx">                 return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
</span><span class="cx"> 
</span><span class="cx">         // Unzip can use a lot of memory, but not this much hopefully
</span><del>-        @ini_set('memory_limit', '256M');
</del><ins>+        @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
</ins><span class="cx"> 
</span><span class="cx">         $needed_dirs = array();
</span><span class="cx">         $to = trailingslashit($to);
</span></span></pre></div>
<a id="trunkwpadminincludesimageeditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/image-edit.php (17748 => 17749)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/image-edit.php        2011-04-28 15:24:49 UTC (rev 17748)
+++ trunk/wp-admin/includes/image-edit.php        2011-04-28 16:25:36 UTC (rev 17749)
</span><span class="lines">@@ -391,7 +391,7 @@
</span><span class="cx"> 
</span><span class="cx"> function stream_preview_image($post_id) {
</span><span class="cx">         $post = get_post($post_id);
</span><del>-        @ini_set('memory_limit', '256M');
</del><ins>+        @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
</ins><span class="cx">         $img = load_image_to_edit( $post_id, $post-&gt;post_mime_type, array(400, 400) );
</span><span class="cx"> 
</span><span class="cx">         if ( !is_resource($img) )
</span><span class="lines">@@ -496,7 +496,7 @@
</span><span class="cx">         $return = new stdClass;
</span><span class="cx">         $success = $delete = $scaled = $nocrop = false;
</span><span class="cx">         $post = get_post($post_id);
</span><del>-        @ini_set('memory_limit', '256M');
</del><ins>+        @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
</ins><span class="cx">         $img = load_image_to_edit($post_id, $post-&gt;post_mime_type);
</span><span class="cx"> 
</span><span class="cx">         if ( !is_resource($img) ) {
</span></span></pre></div>
<a id="trunkwpincludesdefaultconstantsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-constants.php (17748 => 17749)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-constants.php        2011-04-28 15:24:49 UTC (rev 17748)
+++ trunk/wp-includes/default-constants.php        2011-04-28 16:25:36 UTC (rev 17749)
</span><span class="lines">@@ -24,6 +24,10 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
+                define( 'WP_MAX_MEMORY_LIMIT', '256M' );
+        }
+
</ins><span class="cx">         /**
</span><span class="cx">          * The $blog_id global, which you can change in the config allows you to create a simple
</span><span class="cx">          * multiple blog installation using just one WordPress and changing $blog_id around.
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (17748 => 17749)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2011-04-28 15:24:49 UTC (rev 17748)
+++ trunk/wp-includes/media.php        2011-04-28 16:25:36 UTC (rev 17749)
</span><span class="lines">@@ -250,7 +250,7 @@
</span><span class="cx">                 return __('The GD image library is not installed.');
</span><span class="cx"> 
</span><span class="cx">         // Set artificially high because GD uses uncompressed images in memory
</span><del>-        @ini_set('memory_limit', '256M');
</del><ins>+        @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
</ins><span class="cx">         $image = imagecreatefromstring( file_get_contents( $file ) );
</span><span class="cx"> 
</span><span class="cx">         if ( !is_resource( $image ) )
</span></span></pre></div>
<a id="trunkwpsettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-settings.php (17748 => 17749)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-settings.php        2011-04-28 15:24:49 UTC (rev 17748)
+++ trunk/wp-settings.php        2011-04-28 16:25:36 UTC (rev 17749)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> require( ABSPATH . WPINC . '/default-constants.php' );
</span><span class="cx"> require( ABSPATH . WPINC . '/version.php' );
</span><span class="cx"> 
</span><del>-// Set initial default constants including WP_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
</del><ins>+// Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
</ins><span class="cx"> wp_initial_constants( );
</span><span class="cx"> 
</span><span class="cx"> // Disable magic quotes at runtime. Magic quotes are added using wpdb later in wp-settings.php.
</span></span></pre>
</div>
</div>

</body>
</html>