[wp-trac] [WordPress Trac] #29525: New media - media-new.php broken
WordPress Trac
noreply at wordpress.org
Fri Sep 5 05:27:49 UTC 2014
#29525: New media - media-new.php broken
--------------------------------+-----------------------------
Reporter: aliwebdesarrollo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 3.8.3
Severity: normal | Keywords:
Focuses: ui, administration |
--------------------------------+-----------------------------
1 - Go to Media
2 - Upload a new media file (image file) with regular or multi-upload
3 - Click Upload
4 - media-new.php return blank page without a message.
I found that this is a very common bug in a lot of forums and suddenly i
start debug the media-new.php file, to find where its brokes.
It tooks me a while but suddenly i found, it was in the GD class (i also
try with imagick class and also broke). Apparently this class is using the
function "file_get_contents()" witch is not recommended for this cases
instead after a while fighting with this i change this function to
"readfile()" and suddenly the file upload perfect.
In wordpress 3.8.3 look into /wp-includes/class-wp-image-editor-gd.php
line 104
The change will be:
remove:
$this->image = @imagecreatefromstring( file_get_contents( $this->file ) );
change by:
$this->image = @imagecreatefromstring( readfile( $this->file ) );
The most important is that: Readfile will read the file directly into the
output buffer, and file_get_contents will load the file into memory, when
you echo the result the data is copied from memory to the output buffer
effectively using 2 times the memory of readfile. (
http://stackoverflow.com/questions/20095175/php-readfile-vs-file-get-
contents#answer-20095276)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29525>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list