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.
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:
As opposed to
(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.