function action_plugin_deactivation($file) { // Remove the periodical execution event CronTab::delete_cronjob('incoming_links'); // Clear the cached links Cache::expire('incoming_links'); }
public function test_has_group() { Cache::expire(array('*', 'bar'), 'glob'); $this->assertFalse(Cache::has_group('foo'), 'The cache has a group that was explicitly expired.'); Cache::set(array('foo', 'bar'), 'a value'); $this->assertTrue(Cache::has_group('foo'), 'The cache does not have a group that was explicitly set.'); }
public function action_plugin_deactivation($file = '') { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { $class_name = strtolower(get_class($this)); // dump our cached list Cache::expire($class_name . ':list'); } }
public function test_expire() { $value = rand(0, 999999); Cache::set('habari:test', $value); $this->assert_true(Cache::has('habari:test'), 'Cache value not stored as expected.'); Cache::expire('habari:test'); $this->assert_false(Cache::has('habari:test'), 'Cache value did not expire as expected.'); }
function action_plugin_deactivation($file) { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { // remove the module from the dash if it is active Modules::remove_by_name('Incoming Links'); // Remove the periodical execution event CronTab::delete_cronjob('incoming_links'); // Clear the cached links Cache::expire('incoming_links'); } }
/** * Invalidates (expires) the cache entries for the give list of URLs. * * @param array $urls An array of urls to clear */ public function cache_invalidate(array $urls) { // account for annonymous user (id=0) $user_ids = array_map(create_function('$a', 'return $a->id;'), Users::get_all()->getArrayCopy()); array_push($user_ids, "0"); // expire the urls for each user id foreach ($user_ids as $user_id) { foreach ($urls as $url) { $request_id = self::get_request_id($user_id, $url); if (Cache::has(array(self::GROUP_NAME, $request_id))) { Cache::expire(array(self::GROUP_NAME, $request_id)); EventLog::log('Clearing request ID: ' . $request_id, 'info', 'plugin', 'StaticCache'); } } } }
public function action_post_delete_after($post) { if (Post::status_name($post->status) == 'published') { Cache::expire($this->cache_name); } }
function clearCache() { Cache::expire('feedburner_stat_site-rank'); Cache::expire('feedburner_stat_visitors-online'); Cache::expire('feedburner_stat_visitors-unique'); Cache::expire('feedburner_stat_actions'); Cache::expire('feedburner_stat_actions-average'); Cache::expire('feedburner_stat_time-total-pretty'); Cache::expire('feedburner_stat_time-average-pretty'); echo '<p>' . _t('Cache has been cleared.') . '</p>'; return true; }
/** * Handles get requests for the dashboard * @todo update check should probably be cron'd and cached, not re-checked every load */ public function get_dashboard() { // Not sure how best to determine this yet, maybe set an option on install, maybe do this: $firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published'))); if (intval($firstpostdate) !== 0) { $firstpostdate = time() - $firstpostdate; } $this->theme->active_time = array('years' => floor($firstpostdate / 31556736), 'months' => floor($firstpostdate % 31556736 / 2629728), 'days' => round($firstpostdate % 2629728 / 86400)); // get the active theme, so we can check it $active_theme = Themes::get_active(); $active_theme = $active_theme->name . ':' . $active_theme->version; // if the active plugin list has changed, expire the updates cache if (Cache::has('dashboard_updates') && Cache::get('dashboard_updates_plugins') != Options::get('active_plugins')) { Cache::expire('dashboard_updates'); } // if the theme version has changed, expire the updates cache if (Cache::has('dashboard_updates') && Cache::get('dashboard_updates_theme') != $active_theme) { Cache::expire('dashboard_updates'); } /* * Check for updates to core and any hooked plugins * cache the output so we don't make a request every load but can still display updates */ if (Cache::has('dashboard_updates')) { $this->theme->updates = Cache::get('dashboard_updates'); } else { $updates = Update::check(); if (!Error::is_error($updates)) { Cache::set('dashboard_updates', $updates); $this->theme->updates = $updates; // cache the set of plugins we just used to check for Cache::set('dashboard_updates_plugins', Options::get('active_plugins')); // cache the active theme we just used to check for Cache::set('dashboard_updates_theme', $active_theme); } else { $this->theme->updates = array(); } } $this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, FALSE), 'tag_count' => Tags::count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, FALSE) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, FALSE) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id))); $this->fetch_dashboard_modules(); // check for first run $u = User::identify(); if (!isset($u->info->experience_level)) { $this->theme->first_run = true; $u->info->experience_level = 'user'; $u->info->commit(); } else { $this->theme->first_run = false; } $this->display('dashboard'); }
public function action_handler_snapshot_delete($handler_vars) { if (!User::identify()->can('snapshot', 'delete')) { Utils::redirect(URL::get('admin', array('page' => 'unauthorized'))); } $timestamp = Controller::get_var('ts'); $snapshots = Options::get('exportsnapshot__snapshots', array()); if (!isset($snapshots[$timestamp])) { die('Unknown snapshot!'); } // expire the snapshot in the cache Cache::expire('exportsnapshot__' . $timestamp); // remove it from the list unset($snapshots[$timestamp]); // write a log event EventLog::log(_t('Export Snapshot deleted!', 'exportsnapshot'), 'info', 'delete', 'ExportSnapshot'); // save the list Options::set('exportsnapshot__snapshots', $snapshots); // and redirect back to the dashboard Utils::redirect(URL::get('admin')); }
public function filter_mollom_update_stats_cron($result = true) { Cache::expire('mollom_stats'); $this->get_stats(); }
} else { // Create diff from two versions. if (!($data = $diff->diff($old['source'], $new['source']))) { pieError('DiffError'); } } if ($GLOBALS['pie']['query_caching']) { // Write to cache. if (!($f = fopen($cache->file($cid), 'w'))) { pieError('CacheWriteError'); } if (!fwrite($f, $data)) { pieError('CacheWriteError'); } fclose($f); $cache->expire('diff', 86400); } $data = explode("\n", trim($data)); $from = array(); $to = array(); foreach ($data as $line) { switch ($line[0]) { case '=': if (!preg_match('/^(\\d+):(\\d+)$/', substr($line, 1), $match)) { pieError('FormatError'); } $from[] = nl2br(htmlspecialchars(substr($old['source'], $match[1], $match[2]))); $to[] = nl2br(htmlspecialchars(substr($old['source'], $match[1], $match[2]))); break; case '+': case '&':
public function set_default_options() { Options::set('darkautumn__bannercolor', '#f9683c'); Options::set('darkautumn__linkscolor', '#5cc5c9'); Options::set('darkautumn__bgcolor', '#fafafa'); Options::set('darkautumn__hovercolor', '#1ce0e7'); Options::set('darkautumn__bannerimage', ''); Options::set('darkautumn__showupperimg', true); Options::set('darkautumn__showlowerimg', true); Options::set('darkautumn__sidenotestag', 'aside'); Options::set('darkautumn__feedtext', 'Atom Feed'); Options::set('darkautumn__maintenancetitle', 'Site Down For Maintenance'); Options::set('darkautumn__blurbtext', 'Enter Some text about you, your site, or both here.'); Options::set('darkautumn__configured', true); if (Cache::has('darkautum_options')) { Cache::expire('darkautum_options'); } }
/** * Initialisation */ public static function init() { self::$path = __DIR__ . '/../tmp/cache'; // self::$expire = 60 * 60 * 24; self::$expire = 60 * 5; }
} pieHead(); if (@$_REQUEST['page']) { // Purge the cache of a single page. $_REQUEST['page'] = pieGetOption($_REQUEST['page']); $_REQUEST['page'] = pieBeautifyName($_REQUEST['page']); if (!$page->isValidName($_REQUEST['page'])) { pieError('PageNameInvalid'); } if (!$page->exists($_REQUEST['page'])) { pieError('PageNotFound'); } $cid = $cache->key('page', array('page' => $_REQUEST['page'])); if (!$cache->exists($cid)) { pieError('PurgeSuccess'); } if ($cache->delete($cid)) { pieNotice('PurgeSuccess'); } else { pieError('PurgeError'); } } else { // Purge the caches of all pages. if ($cache->expire('page', 0)) { pieNotice('ExpirationSuccess'); } else { pieError('ExpirationError'); } } pieLog('edit'); pieTail();
function action_add_template_vars($theme) { $username = Options::get('freshsurf__username'); $password = Options::get('freshsurf__password'); $count = Options::get('freshsurf__count'); if ($username != '' && $password != '') { if (Cache::has('freshsurf__' . $username)) { $response = Cache::get('freshsurf__' . $username); } else { $request = new RemoteRequest("https://{$username}:{$password}@" . self::BASE_URL . "posts/recent?count={$count}", 'GET', 20); $request->execute(); $response = $request->get_response_body(); Cache::set('freshsurf__' . $username, $response); } $delicious = @simplexml_load_string($response); if ($delicious instanceof SimpleXMLElement) { $theme->delicious = $delicious; } else { $theme->delicious = @simplexml_load_string('<posts><post href="#" description="Could not load feed from delicious. Is username/password correct?"/></posts>'); Cache::expire('freshsurf__' . $username); } } else { $theme->delicious = @simplexml_load_string('<posts></posts>'); } }
/** * After an approved comment is deleted, expire the cache */ public function action_comment_delete_after($comment) { if ($comment->status === COMMENT::STATUS_APPROVED) { Cache::expire($this->cache_name); } }
public function updated_config($ui) { $b64_pw = base64_encode($ui->user_pw->value); $ui->save(); Options::set($this->class_name . '__user_pw', $b64_pw); foreach ($this->reports as $rpt => $data) { $cache = $this->class_name . '__' . $rpt; Cache::expire($cache); } return false; }
public function action_post_publish_after($post) { $albumname = $post->info->picasa_album; if (!isset($albumname) || empty($albumname)) { return $out; } Cache::expire(array(__CLASS__, "picasa_albumids")); Cache::expire(array(__CLASS__, "picasa_albumlinks")); }
public function action_block_update_after($block) { if ($block->type == 'lastfm_recent') { Cache::expire('lastrecent__' . $block->title); } }
private function expire_cache() { foreach ($this->cache as $num_tag => $cache_name) { Cache::expire($cache_name); } }
public function action_tag_delete_after($tag) { Cache::expire($this->cache_name); }
public function teardown() { Cache::expire('pluggable_assets'); Options::delete(array('released_pluggable_assets', 'inactive_pluggable_assets')); }
/** * post_update_status action called when the post status field is updated. * Expires the cached sitemap if the status has been changed. * * @param Post $post The post being updated * @param string $new_status the status feild new value */ public function action_post_update_status($post, $new_status) { if ($post->status != $new_status) { Cache::expire('sitemap'); } }