Index: branches/5.2.x/core/units/helpers/skin_helper.php =================================================================== diff -u -N -r14628 -r14699 --- branches/5.2.x/core/units/helpers/skin_helper.php (.../skin_helper.php) (revision 14628) +++ branches/5.2.x/core/units/helpers/skin_helper.php (.../skin_helper.php) (revision 14699) @@ -1,6 +1,6 @@ _getStylesheetPath() . DIRECTORY_SEPARATOR); - while (false !== ($file = $dh->read())) { - if ( preg_match('/admin-(.*)-([\d]+).css/', $file, $rets) ) { - if ($rets[1] == $style_name && $rets[2] > $last_compiled) { - $last_compiled = $rets[2]; - } + $iterator = new DirectoryIterator( $this->_getStylesheetPath() . DIRECTORY_SEPARATOR ); + /* @var $file_info DirectoryIterator */ + + foreach ($iterator as $file_info) { + if ( !$file_info->isFile() ) { + continue; } - } - $dh->close(); + $regs = $this->isSkinFile( $file_info->getFilename() ); + if ( $regs && $regs[1] == $style_name && $regs[2] > $last_compiled ) { + $last_compiled = max($last_compiled, $regs[2]); + } + } + return $last_compiled; } @@ -222,14 +231,29 @@ */ function deleteCompiled() { - $dh = dir($this->_getStylesheetPath() . DIRECTORY_SEPARATOR); + $iterator = new DirectoryIterator( $this->_getStylesheetPath() . DIRECTORY_SEPARATOR ); + /* @var $file_info DirectoryIterator */ - while (false !== ($file = $dh->read())) { - if ( preg_match('/admin-(.*)-([\d]+).css/', $file, $rets) ) { - unlink($dh->path . $file); + foreach ($iterator as $file_info) { + if ( $file_info->isFile() && $this->isSkinFile( $file_info->getFilename() ) ) { + unlink( $file_info->getPathname() ); } } + } - $dh->close(); + /** + * Determines if given file is admin skin file + * + * @param string $filename + * @return array|bool + * @access protected + */ + protected function isSkinFile($filename) + { + if ( preg_match(self::SKIN_REGEXP, $filename, $regs) ) { + return $regs; + } + + return false; } } \ No newline at end of file