Last active
August 6, 2019 19:30
-
-
Save oliverthiele/4b8dea4a5561276a546d to your computer and use it in GitHub Desktop.
Truncate TYPO3 Cache (DB and typo3temp/Cache/*)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
path=`dirname $(readlink -f ${0})`; | |
cd $path | |
echo "Delete typo3temp/Cache/*" | |
rm ../../../../../../typo3temp/Cache/* -rf | |
echo "Truncate all TYPO3 caching tables:" | |
./TruncateDBCache.phpsh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(opcache_reset()) { | |
echo 'OpCache Reset: OK'; | |
} else { | |
echo 'OpCache Reset: Failed.'; | |
} | |
//var_dump(opcache_get_status()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php -q | |
<?php | |
/** | |
* Truncates all TYPO3 cf_% and cache_% database tables | |
*/ | |
function fetchArray($in) { | |
if(is_file($in)) { | |
return include $in; | |
} else { | |
return false; | |
} | |
} | |
$typo3Configuration = fetchArray('../../../../../LocalConfiguration.php'); | |
$db = $typo3Configuration['DB']; | |
$link = mysqli_connect($db['host'], $db['username'], $db['password'], $db['database']) or die ("Error " . mysqli_error($link)); | |
$query = "set names 'utf8'"; | |
$link->query($query); | |
$query = 'SHOW TABLES FROM ' . $db['database'] . ' WHERE Tables_in_' . $db['database'] . ' LIKE \'cf_%\' OR Tables_in_' . $db['database'] . ' LIKE \'cache_%\';'; | |
$result = $link->query($query); | |
if($result) { | |
while($row = mysqli_fetch_array($result)) { | |
$tables[] = $row['Tables_in_' . $db['database']]; | |
$truncateQuery = 'TRUNCATE ' . $row['Tables_in_'. $db['database']] . ';'; | |
echo $truncateQuery . "\n"; | |
$res = $link->query($truncateQuery); | |
} | |
mysqli_free_result($result); | |
} | |
mysqli_close($link); | |
/** | |
* Only for Redis | |
*/ | |
$cacheConfigurations = $typo3Configuration['SYS']['caching']['cacheConfigurations']; | |
foreach ($cacheConfigurations as $key => $cacheConfiguration) { | |
if ($cacheConfiguration['backend'] == 't3lib_cache_backend_RedisBackend' || | |
$cacheConfiguration['backend'] == 'TYPO3\\CMS\\Core\\Cache\\Backend\\RedisBackend' || | |
$cacheConfiguration['backend'] == 'TYPO3\CMS\Core\Cache\Backend\RedisBackend' | |
) { | |
$command = 'redis-cli -n ' . $cacheConfiguration['options']['database'] . ' flushdb'; | |
echo 'Flush Redis DB "' . $cacheConfiguration['options']['database'] . '" for "' . $key . '": '; | |
system($command); | |
} | |
} | |
try { | |
// todo Edit Domain and Path!!! | |
$domain = 'http://dev.oliver-thiele.de/'; | |
$return = file_get_contents($domain . '/typo3conf/ext/ot_website/Resources/Public/Utility/resetOpCache.php'); | |
echo $return . chr(10); | |
} catch (Exception $e) { | |
echo 'Exception: ', $e->getMessage(), "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Path for both files: EXT:extension/Resources/Private/Shell/