Recently, out of the blue and for unknown causes, I’ve had one of the WordPress sites I manage refused to open up the Media Gallery. No changes had supposedly been made to the server according to the web host and furthermore not much has changed other than content for the WordPress installation.

The symptom I originally had was actually something slightly different. Trying to ‘Insert into post’ would yield a long delay, followed by a time out. Because I had not yet updated to a slightly newer version I decided to run that first. This time, Add Media did not open at all.

Thankfully I was not alone in the problem. Now there are a couple of routes recommended.

1. The first, which worked for me, was a simple solution. It requires editing of your wp-config.php file. Enter the following line prior to the require_once line at the bottom:

define('CONCATENATE_SCRIPTS', false );

2. A long and thorough general troubleshooting checklist. This has worked for some others, but I see that the wp-config adjustment appears to be the general fix. Here is the WP 3.5 Troubleshooting Master List. Master lists for other versions are available, just search them through Google if needed.

If the wp-config.php adjustment worked for you, you may be wondering why this was needed.

CONCATENATE_SCRIPTS

I could not find much of an explanation on why this was the fix, and more so what it does! I decided to track it down a bit through code. This is referenced in a couple of wordpress files, namely script-loader.php and class-wp-editor.php which branch out to other files going deeper. Thankfully the well documented files tells us this:

* define(‘CONCATENATE_SCRIPTS’, false); disables compression and concatenation of scripts and CSS,

also interesting to note that plugins can affect these (install any, lately?):

 * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
* to temporarily override the above settings. 

Concatination happens when apply_filters modifies data in the hook script_loader_src in class.wp-scripts.

Generally at this point, I still can’t say why any of this would break without change to WordPress and another blog working just fine. I’d like to say it has something to do with the server, but it would take too much time to narrow down what piece of code in this process would get affected.

The end result of CONCATENATE_SCRIPTS left on basically appears to adjust the end result by dynamically generating scripts which are called with a single line like such:

<script type='text/javascript' src='http://www.migee.com/wp-admin/load-scripts.php?c=1&amp;load%5B%5D=jquery,utils,quicktags,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,underscore,backbone,media-models,plupl&amp;load%5B%5D=oad,plupload-html5,plupload-flash,plupload-silverlight,plupload-html4,json2,wp-plupload,media-views&amp;ver=3.5.1'></script>

As opposed to

<script type='text/javascript' src='http://www.migee.com/wp-includes/js/media-models.min.js?ver=3.5.1'></script>
<script type='text/javascript' src='http://www.migee.com/wp-includes/js/plupload/plupload.js?ver=1.5.5'></script>
<script type='text/javascript' src='http://www.migee.com/wp-includes/js/plupload/plupload.html5.js?ver=1.5.5'></script>
<script type='text/javascript' src='http://www.migee.com/wp-includes/js/plupload/plupload.flash.js?ver=1.5.5'></script>

(repeated, Ad nauseam)

Stylesheets are done in the same fashion. This is done to improve performance from what I gather.

If anyone cares to dig further I’d love to know why this suddenly stopped working. I’ve heard of people having the host fix it by changing settings, but without stating specifically what it was.

No Comments

There are no comments related to this article.

Leave a Reply

Your email address will not be published. Required fields are marked *