<commit_before><?php
namespace TYPO3\FLOW3\Command;

/*                                                                        *
 * This script belongs to the FLOW3 framework.                            *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 * of the License, or (at your option) any later version.                 *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */

use TYPO3\FLOW3\Annotations as FLOW3;
use TYPO3\FLOW3\Cli\Response;
use TYPO3\FLOW3\Utility\Files;

/**
 * Command controller for managing caches
 *
 * NOTE: This command controller will run in compile time (as defined in the package bootstrap)
 *
 * @FLOW3\Scope("singleton")
 */
class CacheCommandController extends \TYPO3\FLOW3\Cli\CommandController {

	/**
	 * @var \TYPO3\FLOW3\Cache\CacheManager
	 */
	protected $cacheManager;

	/**
	 * @var \TYPO3\FLOW3\Core\LockManager
	 */
	protected $lockManager;

	/**
	 * @var \TYPO3\FLOW3\Package\PackageManagerInterface
	 */
	protected $packageManager;

	/**
	 * Injects the cache manager
	 *
	 * @param \TYPO3\FLOW3\Cache\CacheManager $cacheManager
	 * @return void
	 */
	public function injectCacheManager(\TYPO3\FLOW3\Cache\CacheManager $cacheManager) {
		$this->cacheManager = $cacheManager;
	}

	/**
	 * Injects the Lock Manager
	 *
	 * @param \TYPO3\FLOW3\Core\LockManager $lockManager
	 * @return void
	 */
	public function injectLockManager(\TYPO3\FLOW3\Core\LockManager $lockManager) {
		$this->lockManager = $lockManager;
	}

	/**
	 * @param \TYPO3\FLOW3\Package\PackageManagerInterface $packageManager
	 * @return void
	 */
	public function injectPackageManager(\TYPO3\FLOW3\Package\PackageManagerInterface $packageManager) {
		$this->packageManager =  $packageManager;
	}

	/**
	 * Flush all caches
	 *
	 * The flush command flushes all caches, including code caches, which have been
	 * registered with FLOW3's Cache Manager.
	 *
	 * If fatal errors caused by a package prevent the compile time bootstrap
	 * from running, the removal of any temporary data can be forced by specifying
	 * the option <b>--force</b>.
	 *
	 * This command does not remove the precompiled data provided by frozen
	 * packages unless the <b>--force</b> option is used.
	 *
	 * @param boolean $force Force flushing of any temporary data
	 * @return void
	 * @see typo3.flow3:cache:warmup
	 * @see typo3.flow3:package:freeze
	 * @see typo3.flow3:package:refreeze
	 */
	public function flushCommand($force = FALSE) {

			// Internal note: the $force option is evaluated early in the FLOW3
			// bootstrap in order to reliably flush the temporary data before any
			// other code can cause fatal errors.

		$this->cacheManager->flushCaches();
		$this->outputLine('Flushed all caches.');
		if ($this->lockManager->isSiteLocked()) {
			$this->lockManager->unlockSite();
		}

		$numberOfFrozenPackages = 0;
		foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) {
			if ($this->packageManager->isPackageFrozen($packageKey)) {
				$numberOfFrozenPackages ++;
			}
		}
		if ($numberOfFrozenPackages > 0) {
			$this->outputLine();
			$this->output('NOTE: ');
			if ($numberOfFrozenPackages === 1) {
				$this->output('There is one frozen package. ');
			} else {
				$this->output('There are %d frozen packages. ', array($numberOfFrozenPackages));
			}
			$this->outputLine('Make sure to call typo3.flow3:package:refreeze or specify the --force option of the cache:flush command in order to recreate precompiled reflection data for frozen packages.');
		}

		$this->sendAndExit(0);<commit_msg>[TASK] Fix hints about frozen packages to cache:flush command<commit_after><?php
namespace TYPO3\FLOW3\Command;

/*                                                                        *
 * This script belongs to the FLOW3 framework.                            *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 * of the License, or (at your option) any later version.                 *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */

use TYPO3\FLOW3\Annotations as FLOW3;
use TYPO3\FLOW3\Cli\Response;
use TYPO3\FLOW3\Utility\Files;

/**
 * Command controller for managing caches
 *
 * NOTE: This command controller will run in compile time (as defined in the package bootstrap)
 *
 * @FLOW3\Scope("singleton")
 */
class CacheCommandController extends \TYPO3\FLOW3\Cli\CommandController {

	/**
	 * @var \TYPO3\FLOW3\Cache\CacheManager
	 */
	protected $cacheManager;

	/**
	 * @var \TYPO3\FLOW3\Core\LockManager
	 */
	protected $lockManager;

	/**
	 * @var \TYPO3\FLOW3\Package\PackageManagerInterface
	 */
	protected $packageManager;

	/**
	 * Injects the cache manager
	 *
	 * @param \TYPO3\FLOW3\Cache\CacheManager $cacheManager
	 * @return void
	 */
	public function injectCacheManager(\TYPO3\FLOW3\Cache\CacheManager $cacheManager) {
		$this->cacheManager = $cacheManager;
	}

	/**
	 * Injects the Lock Manager
	 *
	 * @param \TYPO3\FLOW3\Core\LockManager $lockManager
	 * @return void
	 */
	public function injectLockManager(\TYPO3\FLOW3\Core\LockManager $lockManager) {
		$this->lockManager = $lockManager;
	}

	/**
	 * @param \TYPO3\FLOW3\Package\PackageManagerInterface $packageManager
	 * @return void
	 */
	public function injectPackageManager(\TYPO3\FLOW3\Package\PackageManagerInterface $packageManager) {
		$this->packageManager =  $packageManager;
	}

	/**
	 * Flush all caches
	 *
	 * The flush command flushes all caches, including code caches, which have been
	 * registered with FLOW3's Cache Manager.
	 *
	 * If fatal errors caused by a package prevent the compile time bootstrap
	 * from running, the removal of any temporary data can be forced by specifying
	 * the option <b>--force</b>.
	 *
	 * This command does not remove the precompiled data provided by frozen
	 * packages unless the <b>--force</b> option is used.
	 *
	 * @param boolean $force Force flushing of any temporary data
	 * @return void
	 * @see typo3.flow3:cache:warmup
	 * @see typo3.flow3:package:freeze
	 * @see typo3.flow3:package:refreeze
	 */
	public function flushCommand($force = FALSE) {

			// Internal note: the $force option is evaluated early in the FLOW3
			// bootstrap in order to reliably flush the temporary data before any
			// other code can cause fatal errors.

		$this->cacheManager->flushCaches();
		$this->outputLine('Flushed all caches.');
		if ($this->lockManager->isSiteLocked()) {
			$this->lockManager->unlockSite();
		}

		$frozenPackages = array();
		foreach (array_keys($this->packageManager->getActivePackages()) as $packageKey) {
			if ($this->packageManager->isPackageFrozen($packageKey)) {
				$frozenPackages[] = $packageKey;
			}
		}
		if ($frozenPackages !== array()) {
			$this->outputFormatted(PHP_EOL . 'Please note that the following package' . (count($frozenPackages) === 1 ? ' is' : 's are') . ' currently frozen: ' . PHP_EOL);
			$this->outputFormatted(implode(PHP_EOL, $frozenPackages) . PHP_EOL, array(), 2);

			$message = 'As code and configuration changes in these packages are not detected, the application may respond ';
			$message .= 'unexpectedly if modifications were done anyway or the remaining code relies on these changes.' . PHP_EOL . PHP_EOL;
			$message .= 'You may call <b>package:refreeze all</b> in order to refresh frozen packages or use the <b>--force</b> ';
			$message .= 'option of this <b>cache:flush</b> command to flush caches if FLOW3 becomes unresponsive.' . PHP_EOL;
			$this->outputFormatted($message, array($frozenPackages));
		}

		$this->sendAndExit(0);
{'fraction_non_alphanumeric': 0.10866642219777534, 'fraction_numerical': 0.01124556900134458, 'mean_word_length': 2.649420160570919, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 56, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6266925', 'n_tokens_mistral': 2523, 'n_tokens_neox': 2302, 'n_words': 678}