Add new media drag and drop hangs on Crunching…

So no results, then this technique
can often be your saviour
Reduce the problem to the simplest
showing bad behaviour

Caravan Live at RoSfest 2014 – file orignally named !.jpg

I had an interesting problem in my development machine. It turned out I was not the first to have the problem. I searched for Crunching… and found TRAC #30052.

So I went about analysing it, discovered what caused my problem, updated the TRAC with my comments concluding that it was probably similar but different.

The next day I tried to reproduce the problem as stated. I couldn’t, but I was able to produce the problem using a different technique; one which I could explain and reproduce on a number of servers.

Problem creation

The simplest way to recreate TRAC #30052 – Add New Media Drag and Drop Hangs on Crunching is:

  1. Define( WP_DEBUG, ‘true’); in wp-config.php
  2. Rename an image to !.jpg
  3. Upload it using Media > Add New

Unexpected result

The Crunching… never ends and you get to see

Notice:  Undefined index: extension in 
/home/herb/public_html/wp-includes/class-wp-image-editor.php on line 360


Simplest explantion

  • WordPress attempts to sanitize the file name by removing special characters
  • It goes a bit overboard
  • The file name becomes jpg
  • Things are mostly fine until it tries to determine the file extension from the sanitized file name

What’s it supposed to do?

I don’t know. The choices would appear to be:

  1. Make up a file name, using numbers. e.g. start from 1.jpg
  2. Tell the user about the problem and ask them to change the file name so that it will work
  3. Nothing

My preference is for option 1.

But we still have to ask what about processing a file called !.!



Related questions: