[wp-trac] [WordPress Trac] #20057: Media upload for multi-webserver setups introduces a nasty race condition that could corrupt uploaded files

WordPress Trac wp-trac at lists.automattic.com
Wed Jul 25 10:46:07 UTC 2012


#20057: Media upload for multi-webserver setups introduces a nasty race condition
that could corrupt uploaded files
--------------------------+------------------------------
 Reporter:  archon810     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  3.3.1
 Severity:  major         |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by archon810):

 Alright, this seems to work, I guess. I tested with xmlrpc and regular web
 uploads.

 {{{
 /**
 * Prepend the server name to file uploads
 *
 * @param string $filename
 * @param string $filename_raw
 */
 function my_sanitize_file_name($filename, $filename_raw) {
   $prefix = trim(`hostname`)."_";

   if(!preg_match("/^$prefix/", $filename))
     $filename = $prefix . $filename;

   return $filename;
 }
 add_filter('sanitize_file_name', 'my_sanitize_file_name', 10, 2);
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20057#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list