Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit 54d9232

Browse files
author
Stefano Kowalke
committed
Clear opcode cache
Add command to clear the opcode cache at all or a specific file Resolves: #70
1 parent d75043a commit 54d9232

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Classes/Command/CacheApiCommandController.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,33 @@ public function clearAllCachesCommand() {
6060
}
6161

6262
/**
63-
* Clear system cache
63+
* Clear system cache.
6464
*
6565
* @return void
6666
*/
6767
public function clearSystemCacheCommand() {
6868
$this->cacheApiService->clearSystemCache();
6969
$this->outputLine('System cache has been cleared');
7070
}
71+
72+
/**
73+
* Clears the opcode cache.
74+
*
75+
* @param string|NULL $fileAbsPath The file as absolute path to be cleared
76+
* or NULL to clear completely.
77+
*
78+
* @return void
79+
*/
80+
public function clearAllActiveOpcodeCacheCommand($fileAbsPath = NULL) {
81+
$this->cacheApiService->clearAllActiveOpcodeCache($fileAbsPath);
82+
83+
if ($fileAbsPath !== NULL) {
84+
$this->outputLine(sprintf('The opcode cache for the file %s has been cleared', $fileAbsPath));
85+
} else {
86+
$this->outputLine('The complete opcode cache has been cleared');
87+
}
88+
}
89+
7190
/**
7291
* Clear configuration cache (temp_CACHED_..).
7392
*

Classes/Service/CacheApiService.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ public function clearSystemCache() {
117117
$this->dataHandler->clear_cacheCmd('system');
118118
}
119119

120+
/**
121+
* Clears the opcode cache.
122+
*
123+
* @param string|NULL $fileAbsPath The file as absolute path to be cleared
124+
* or NULL to clear completely.
125+
*
126+
* @return void
127+
*/
128+
public function clearAllActiveOpcodeCache($fileAbsPath = NULL) {
129+
$this->clearAllActiveOpcodeCacheWrapper($fileAbsPath);
130+
}
131+
120132
/**
121133
* Clear all caches except the page cache.
122134
* This is especially useful on big sites when you can't
@@ -143,4 +155,16 @@ public function clearAllExceptPageCache() {
143155

144156
return $toBeFlushed;
145157
}
158+
159+
/**
160+
* Clears the opcode cache. This just wraps the static call for testing purposes.
161+
*
162+
* @param string|NULL $fileAbsPath The file as absolute path to be cleared
163+
* or NULL to clear completely.
164+
*
165+
* @return void
166+
*/
167+
protected function clearAllActiveOpcodeCacheWrapper($fileAbsPath) {
168+
\TYPO3\CMS\Core\Utility\OpcodeCacheUtility::clearAllActive($fileAbsPath);
169+
}
146170
}

0 commit comments

Comments
 (0)