<commit_before><?php
/**
 * Clean all caches Shell Script
 *
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details at
 * http://www.gnu.org/copyleft/lgpl.html
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * @category    Mage
 * @package     Mage_Shell
 * @author      <NAME> <<EMAIL>>
 * @version     1
 */

require_once 'abstract.php';

class Yameveo_Shell_CleanCache extends Mage_Shell_Abstract
{

    /**
     * Cleans image cache using catalog/product_image model.
     *
     */
    protected function cleanImageCache()
    {
        try {
            echo "Cleaning image cache... ";
            flush();
            echo Mage::getModel('catalog/product_image')->clearCache();
            echo "[OK]" . PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    /**
     * Cleans magento data cache:
     * - config,
     * - layout,
     * - block_html
     * - translate,
     * - collections,
     * - eav,
     * - config_api
     */
    protected function cleanDataCache()
    {
        try {
            echo "Cleaning data cache:" . PHP_EOL;
            flush();
            $types = Mage::app()->getCacheInstance()->getTypes();
            foreach ($types as $type => $data) {
                echo "Removing $type ... ";
                echo Mage::app()->getCacheInstance()->clean($data["tags"]) ? "[OK]" : "[ERROR]";
                echo PHP_EOL;
            }
            echo PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    protected function cleanMergedJSCSS()
    {
        try {
            echo "Cleaning merged JS/CSS... ";
            flush();
            Mage::getModel('core/design_package')->cleanMergedJsCss();
            Mage::dispatchEvent('clean_media_cache_after');
            echo "[OK]" . PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    protected function cleanStoredCache()
    {
        try {
            echo "Cleaning stored cache... ";
            flush();
            echo Mage::app()->getCacheInstance()->clean() ? "[OK]" : "[ERROR]";
            echo PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    /**
     * Does a rmdir on:
     * - cache,
     * - var/full_page_cache
     * - var/minifycache
     * - session dir
     *
     * @todo verify these functions
     * @todo check var dir for any other cleanable subdirs.
     */
    protected function cleanFiles()
    {
        try {
            echo "Cleaning files:" . PHP_EOL;
            flush();
            echo "Cache... ";
            $this->_rrmdirContent(Mage::getBaseDir('cache'));
            echo "[OK]" . PHP_EOL;
            echo "Full page cache... ";
            $this->_rrmdirContent(Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'full_page_cache');
            echo "[OK]" . PHP_EOL;
            echo "Minify cache... ";
            $this->_rrmdirContent(Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'minifycache');
            echo "[OK]" . PHP_EOL;
            echo "Session... ";
            $this->_rrmdirContent(Mage::getBaseDir('session'));
            echo "[OK]" . PHP_EOL;
            echo PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    protected function cleanAccelerator()
    {
        try {
            echo "Cleaning accelerator... ";
            flush();
            accelerator_reset();
            echo "[OK]" . PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }
<commit_msg>Update shell/cleanCache.php<commit_after><?php
/**
 * Clean all caches Shell Script
 *
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details at
 * http://www.gnu.org/copyleft/lgpl.html
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * @category    Mage
 * @package     Mage_Shell
 * @author      <NAME> <<EMAIL>>
 * @version     1
 */

require_once 'abstract.php';

class Yameveo_Shell_CleanCache extends Mage_Shell_Abstract
{

    /**
     * Cleans image cache using catalog/product_image model.
     *
     */
    protected function cleanImageCache()
    {
        try {
            echo "Cleaning image cache... ";
            flush();
            echo Mage::getModel('catalog/product_image')->clearCache();
            echo "[OK]" . PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    /**
     * Cleans magento data cache:
     * - config,
     * - layout,
     * - block_html
     * - translate,
     * - collections,
     * - eav,
     * - config_api
     */
    protected function cleanDataCache()
    {
        try {
            echo "Cleaning data cache:" . PHP_EOL;
            flush();
            $types = Mage::app()->getCacheInstance()->getTypes();
            foreach ($types as $type => $data) {
                echo "Removing $type ... ";
                echo Mage::app()->getCacheInstance()->clean($data["tags"]) ? "[OK]" : "[ERROR]";
                echo PHP_EOL;
            }
            echo PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    protected function cleanMergedJSCSS()
    {
        try {
            echo "Cleaning merged JS/CSS... ";
            flush();
            Mage::getModel('core/design_package')->cleanMergedJsCss();
            Mage::dispatchEvent('clean_media_cache_after');
            echo "[OK]" . PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    protected function cleanStoredCache()
    {
        try {
            echo "Cleaning stored cache... ";
            flush();
            echo Mage::app()->getCacheInstance()->clean() ? "[OK]" : "[ERROR]";
            echo PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    /**
     * Does a rmdir on:
     * - cache,
     * - var/full_page_cache
     * - var/minifycache
     * - session dir
     *
     * @todo verify these functions
     * @todo check var dir for any other cleanable subdirs.
     */
    protected function cleanFiles()
    {
        try {
            echo "Cleaning files:" . PHP_EOL;
            flush();
            echo "Cache... ";
            $this->_rrmdirContent(Mage::getBaseDir('cache'));
            echo "[OK]" . PHP_EOL;
            $full_page_dir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'full_page_cache';
            if(is_dir($full_page_dir)) {
                echo "Full page cache... ";
                $this->_rrmdirContent($full_page_dir);
                echo "[OK]" . PHP_EOL;
            }
            $minify_dir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'minifycache';
            if(is_dir($minify_dir)) {
                echo "Minify cache... ";
                $this->_rrmdirContent($minify_dir);
                echo "[OK]" . PHP_EOL;
            }
            echo "Session... ";
            $this->_rrmdirContent(Mage::getBaseDir('session'));
            echo "[OK]" . PHP_EOL;
            echo PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

    protected function cleanAccelerator()
    {
        try {
            echo "Cleaning accelerator... ";
            flush();
            accelerator_reset();
            echo "[OK]" . PHP_EOL . PHP_EOL;
        } catch (Exception $e) {
            die("[ERROR:" . $e->getMessage() . "]" . PHP_EOL);
        }
    }

{'fraction_non_alphanumeric': 0.1373007912626769, 'fraction_numerical': 0.003789145213418032, 'mean_word_length': 1.7663378545006165, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3473370', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2615, 'n_words': 669}