Index: branches/5.2.x/core/units/helpers/image_helper.php =================================================================== diff -u -N -r16129 -r16247 --- branches/5.2.x/core/units/helpers/image_helper.php (.../image_helper.php) (revision 16129) +++ branches/5.2.x/core/units/helpers/image_helper.php (.../image_helper.php) (revision 16247) @@ -1,6 +1,6 @@ fileHelper->makeRelative($params))); $dst_image = preg_replace( '/^' . preg_quote($src_path, '/') . '(.*)\.(.*)$/', - $src_path_escaped . DIRECTORY_SEPARATOR . 'resized\\1_' . $params_hash . '.\\2', + $src_path_escaped . '\\1_' . $params_hash . '.\\2', $src_image ); + // Keep resized version of all images under "/system/thumbs/" folder. + $dst_image = preg_replace('/^' . preg_quote(FULL_PATH, '/') . '/', '', $dst_image, 1); + $dst_image = FULL_PATH . THUMBS_PATH . $dst_image; + $this->fileHelper->CheckFolder( dirname($dst_image) ); if (!file_exists($dst_image) || filemtime($src_image) > filemtime($dst_image)) { Index: branches/5.2.x/core/units/images/images_config.php =================================================================== diff -u -N -r15433 -r16247 --- branches/5.2.x/core/units/images/images_config.php (.../images_config.php) (revision 15433) +++ branches/5.2.x/core/units/images/images_config.php (.../images_config.php) (revision 16247) @@ -1,6 +1,6 @@ Array ( 'clean_catalog_images' => Array ('EventName' => 'OnCleanImages', 'RunSchedule' => '0 0 * * 0', 'Status' => STATUS_DISABLED), - 'clean_resized_catalog_images' => Array ('EventName' => 'OnCleanResizedImages', 'RunSchedule' => '0 0 1 * *', 'Status' => STATUS_DISABLED), ), 'IDField' => 'ImageId', @@ -181,4 +180,4 @@ ), ), ), - ); \ No newline at end of file + ); Index: branches/5.2.x/core/kernel/constants.php =================================================================== diff -u -N -r15608 -r16247 --- branches/5.2.x/core/kernel/constants.php (.../constants.php) (revision 15608) +++ branches/5.2.x/core/kernel/constants.php (.../constants.php) (revision 16247) @@ -1,6 +1,6 @@ Array ('subitem' => true), - 'OnCleanResizedImages' => Array ('subitem' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); @@ -472,25 +471,4 @@ } } - /** - * [SCHEDULED TASK] Remove all images from "/system/images/resized" and "/system/images/pending/resized" folders - * - * @param kEvent $event - */ - function OnCleanResizedImages($event) - { - $images = glob(FULL_PATH . IMAGES_PATH . 'resized/*.*'); - if ($images) { - foreach ($images as $image) { - unlink($image); - } - } - - $images = glob(FULL_PATH . IMAGES_PENDING_PATH . 'resized/*.*'); - if ($images) { - foreach ($images as $image) { - unlink($image); - } - } - } -} \ No newline at end of file +} Index: branches/5.2.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r16241 -r16247 --- branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 16241) +++ branches/5.2.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 16247) @@ -1,6 +1,6 @@ deleteTempFiles($tmp_path); - if ( file_exists($tmp_path . 'resized/') ) { - $this->deleteTempFiles($tmp_path . 'resized/'); + $thumbs_path = preg_replace('/^' . preg_quote(FULL_PATH, '/') . '/', '', $tmp_path, 1); + $thumbs_path = FULL_PATH . THUMBS_PATH . $thumbs_path; + + if ( file_exists($thumbs_path) ) { + $this->deleteTempFiles($thumbs_path); } } @@ -3215,12 +3218,12 @@ $files = glob($path . '*.*'); $max_file_date = strtotime('-1 day'); - foreach ($files as $file) { - if (filemtime($file) < $max_file_date) { + foreach ( $files as $file ) { + if ( filemtime($file) < $max_file_date ) { unlink($file); } } - } + } /** * Checks, that flash uploader is allowed to perform upload 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); + } + } + } + }