本文整理汇总了PHP中GO::clearCache方法的典型用法代码示例。如果您正苦于以下问题:PHP GO::clearCache方法的具体用法?PHP GO::clearCache怎么用?PHP GO::clearCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GO
的用法示例。
在下文中一共展示了GO::clearCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uninstall
/**
* Delete's the module's tables etc.
*
* @return boolean
*/
public function uninstall()
{
$oldIgnore = \GO::setIgnoreAclPermissions();
// //call deleteUser for each user
// $stmt = Model\User::model()->find(array('ignoreAcl'=>true));
// while($user = $stmt->fetch()){
// call_user_func(array(get_class($this),'deleteUser'), $user);
// }
//Uninstall cron jobs for this module
$cronClasses = $this->findClasses('cron');
foreach ($cronClasses as $class) {
$jobs = Cron\CronJob::model()->findByAttribute('job', $class->getName());
foreach ($jobs as $job) {
$job->delete();
}
}
//delete all models from the Model\ModelType table.
//They are used for faster linking and search cache. Each linkable model is mapped to an id in this table.
$models = $this->getModels();
$modelTypes = array();
foreach ($models as $model) {
$modelType = Model\ModelType::model()->findSingleByAttribute('model_name', $model->getName());
if ($modelType) {
$modelTypes[] = $modelType->id;
$modelType->delete();
}
}
if (!empty($modelTypes)) {
$sql = "DELETE FROM `go_search_cache` WHERE model_type_id IN (" . implode(',', $modelTypes) . ")";
\GO::getDbConnection()->query($sql);
$stmt = GO::getDbConnection()->query('SHOW TABLES');
while ($r = $stmt->fetch()) {
$tableName = $r[0];
if (substr($tableName, 0, 9) == 'go_links_' && !is_numeric(substr($tableName, 9, 1))) {
$sql = "DELETE FROM `{$tableName}` WHERE model_type_id IN (" . implode(',', $modelTypes) . ")";
\GO::getDbConnection()->query($sql);
}
}
}
$sqlFile = $this->path() . 'install/uninstall.sql';
if (file_exists($sqlFile)) {
$queries = Util\SQL::getSqlQueries($sqlFile);
foreach ($queries as $query) {
\GO::getDbConnection()->query($query);
}
}
\GO::clearCache();
\GO::setIgnoreAclPermissions($oldIgnore);
return true;
}
示例2: actionUpgrade
protected function actionUpgrade($params)
{
if (!$this->isCli()) {
echo '<pre>';
}
if (!version_compare(phpversion(), "5.3", ">=")) {
exit("You are running a PHP version older than 5.3. PHP 5.3 or greater is required to run Group-Office " . \GO::config()->version);
}
$this->lockAction();
GO::setIgnoreAclPermissions(true);
GO::session()->runAsRoot();
\GO::clearCache();
\GO\Base\Db\Columns::$forceLoad = true;
//don't be strict in upgrade process
\GO::getDbConnection()->query("SET sql_mode=''");
$v3 = $this->_checkV3();
$logDir = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . 'log/upgrade/');
$logDir->create();
global $logFile;
$logFile = $logDir->path() . '/' . date('Ymd_Gi') . '.log';
touch($logFile);
if (!is_writable($logFile)) {
die('Fatal error: Could not write to log file');
}
ob_start("GO\\Core\\Controller\\MaintenanceController::ob_upgrade_log");
echo "Updating " . \GO::config()->product_name . " database\n";
//build an array of all update files. The queries are indexed by timestamp
//so they will all be executed in the right order.
$u = array();
require \GO::config()->root_path . 'install/updates.php';
//put the updates in an extra array dimension so we know to which module
//they belong too.
foreach ($updates as $timestamp => $updatequeries) {
$u["{$timestamp}"]['core'] = $updatequeries;
}
$modules = \GO::modules()->getAllModules();
while ($module = array_shift($modules)) {
if ($module->isAvailable()) {
$updatesFile = $module->path . 'install/updates.php';
if (!file_exists($updatesFile)) {
$updatesFile = $module->path . 'install/updates.inc.php';
}
if (file_exists($updatesFile)) {
$updates = array();
require $updatesFile;
//put the updates in an extra array dimension so we know to which module
//they belong too.
foreach ($updates as $timestamp => $updatequeries) {
$u["{$timestamp}"][$module->id] = $updatequeries;
}
}
}
}
//sort the array by timestamp
ksort($u);
//
// var_dump($u);
// exit();
$currentCoreVersion = \GO::config()->get_setting('version');
if (!$currentCoreVersion) {
$currentCoreVersion = 0;
}
$counts = array();
foreach ($u as $timestamp => $updateQuerySet) {
foreach ($updateQuerySet as $module => $queries) {
//echo "Getting updates for ".$module."\n";
if (!is_array($queries)) {
exit("Invalid queries in module: " . $module);
}
if ($module == 'core') {
$currentVersion = $currentCoreVersion;
} else {
$currentVersion = \GO::modules()->{$module}->version;
}
if (!isset($counts[$module])) {
$counts[$module] = 0;
}
foreach ($queries as $query) {
$counts[$module]++;
if ($counts[$module] > $currentVersion) {
if (substr($query, 0, 7) == 'script:') {
if ($module == 'core') {
$updateScript = \GO::config()->root_path . 'install/updatescripts/' . substr($query, 7);
} else {
$updateScript = \GO::modules()->{$module}->path . 'install/updatescripts/' . substr($query, 7);
}
if (!file_exists($updateScript)) {
die($updateScript . ' not found!');
}
//if(!$quiet)
echo 'Running ' . $updateScript . "\n";
flush();
if (empty($params['test'])) {
require_once $updateScript;
}
} else {
echo 'Excuting query: ' . $query . "\n";
flush();
if (empty($params['test'])) {
try {
//.........这里部分代码省略.........