Index: branches/5.2.x/core/install/upgrades.php =================================================================== diff -u -N -r15608 -r16247 --- branches/5.2.x/core/install/upgrades.php (.../upgrades.php) (revision 15608) +++ branches/5.2.x/core/install/upgrades.php (.../upgrades.php) (revision 16247) @@ -1,6 +1,6 @@ Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Users', 'PortalUserId = ' . $user_id); } } - } \ No newline at end of file + + /** + * Update to 5.2.2-B1 + * + * @param string $mode when called mode {before, after) + */ + public function Upgrade_5_2_2_B1($mode) + { + if ( $mode != 'after' ) { + return; + } + + $this->deleteThumbnails(); + } + + /** + * Deletes folders, containing thumbnails recursively. + * + * @param string $folder Folder. + * + * @return void + */ + protected function deleteThumbnails($folder = WRITEABLE) + { + foreach ( glob($folder . '/*', GLOB_ONLYDIR) as $sub_folder ) { + if ( $sub_folder === WRITEABLE . '/cache' ) { + continue; + } + + if ( basename($sub_folder) === 'resized' ) { + $files = glob($sub_folder . '/*'); + array_map('unlink', $files); + rmdir($sub_folder); + } + else { + $this->deleteThumbnails($sub_folder); + } + } + } + }