Changes between Initial Version and Version 1 of Ticket #26626
- Timestamp:
- 12/15/2013 11:13:52 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #26626 – Description
initial v1 7 7 See http://wordpress.org/support/topic/restore-fails-could-not-create-directory for more information on that. Basically, it boiled down to "WP_Upgrader::unpack_package() uses the basename of the zip file to create a directory in WP_CONTENT_DIR/upgrade/". So, if the zip file name is very long, then a meaningful amount of the potential 256-character limit can be lost. 8 8 9 The guy running Bitnami lost 80 characters to reach his upgrade folder: C:\Program Files\BitNami WAMP Stack\apps\wordpresslucid\htdocs\wp-content/upgrade. That leaves 176 characters.9 The guy running Bitnami lost 80 characters to reach his upgrade folder: `C:\Program Files\BitNami WAMP Stack\apps\wordpresslucid\htdocs\wp-content/upgrade`. That leaves 176 characters. 10 10 11 The plugin he was unpacking needed 98 characters for its longest pathname: /plugins/<slug>/opencloud/symed/Symfony/Component/EventDispatcher/EventDispatcherInterface.php. That leaves 78 characters to spare. Should be plenty... except for WP_Upgrader::unpack_package() wanting to use basename($zipfile) to create a directory for unpacking into. The zipfile did indeed have a filename of over 78 characters long. Boom!11 The plugin he was unpacking needed 98 characters for its longest pathname: `/plugins/<slug>/opencloud/symed/Symfony/Component/EventDispatcher/EventDispatcherInterface.php`. That leaves 78 characters to spare. Should be plenty... except for WP_Upgrader::unpack_package() wanting to use basename($zipfile) to create a directory for unpacking into. The zipfile did indeed have a filename of over 78 characters long. Boom! 12 12 13 13 To prevent other scenarios in which someone might get hit by this, we can just change this line: 14 14 {{{ 15 15 $working_dir = $upgrade_folder . basename($package, '.zip'); 16 16 }}} 17 17 to: 18 18 {{{ 19 19 $working_dir = $upgrade_folder . substr(md5(basename($package, '.zip')), 0, 8); 20 20 }}} 21 21 The use of md5() to prevent collisions might be over-cautious (especially given that WP_Upgrader::unpack_package() already tries to empty out the upgrades directory), but it's also harmless.