Ejemplo n.º 1
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Cache::clear(false, 'session_test');
     Cache::drop('session_test');
     unset($this->storage);
 }
 /**
  * Setup function
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->connection = ConnectionManager::get('test');
     Cache::clear(false, '_cake_method_');
     Cache::enable();
 }
Ejemplo n.º 3
0
 /**
  * testTranslationCaching method
  *
  * @return void
  */
 public function testTranslationCaching()
 {
     $this->skipIf(!Cache::engine('_cake_core_'), 'Missing _cake_core_ cache config, cannot test caching.');
     Configure::write('Config.language', 'cache_test_po');
     // reset internally stored entries
     I18n::clear();
     Cache::clear(false, '_cake_core_');
     $lang = Configure::read('Config.language');
     // make some calls to translate using different domains
     $this->assertEquals('Dom 1 Foo', I18n::translate('dom1.foo', false, 'dom1'));
     $this->assertEquals('Dom 1 Bar', I18n::translate('dom1.bar', false, 'dom1'));
     $domains = I18n::domains();
     $this->assertEquals('Dom 1 Foo', $domains['dom1']['cache_test_po']['LC_MESSAGES']['dom1.foo']);
     // reset internally stored entries
     I18n::clear();
     // now only dom1 should be in cache
     $cachedDom1 = Cache::read('dom1_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 1 Foo', $cachedDom1['LC_MESSAGES']['dom1.foo']);
     $this->assertEquals('Dom 1 Bar', $cachedDom1['LC_MESSAGES']['dom1.bar']);
     // dom2 not in cache
     $this->assertFalse(Cache::read('dom2_' . $lang, '_cake_core_'));
     // translate a item of dom2 (adds dom2 to cache)
     $this->assertEquals('Dom 2 Foo', I18n::translate('dom2.foo', false, 'dom2'));
     // verify dom2 was cached through manual read from cache
     $cachedDom2 = Cache::read('dom2_' . $lang, '_cake_core_');
     $this->assertEquals('Dom 2 Foo', $cachedDom2['LC_MESSAGES']['dom2.foo']);
     $this->assertEquals('Dom 2 Bar', $cachedDom2['LC_MESSAGES']['dom2.bar']);
     // modify cache entry manually to verify that dom1 entries now will be read from cache
     $cachedDom1['LC_MESSAGES']['dom1.foo'] = 'FOO';
     Cache::write('dom1_' . $lang, $cachedDom1, '_cake_core_');
     $this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1'));
 }
Ejemplo n.º 4
0
 /**
  * Execute the ClearCache task.
  *
  * @return void
  */
 public function main()
 {
     Cache::clear(false, '_cake_core_');
     Cache::clear(false, 'database');
     Cache::clear(false, 'acl');
     $this->out('<info>The</info> "<error>deployer clear_cache</error>" <info>command has been executed successfully !</info>', 2);
 }
Ejemplo n.º 5
0
 /**
  * Setup
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Cache::clear(false);
     $this->apiFolderName = 'NonExistingApiPrefixedFolder';
     $this->apiFolderPath = APP . 'Controller' . DS . $this->apiFolderName;
 }
Ejemplo n.º 6
0
 /**
  * Clears the cache
  *
  * @return void
  */
 public function cleanup()
 {
     Cache::clear(false, 'default');
     Cache::clear(false, '_cake_model_');
     Cache::clear(false, '_cake_core_');
     $this->dispatchShell('orm_cache clear');
     $this->dispatchShell('orm_cache build');
 }
Ejemplo n.º 7
0
 public function main()
 {
     if (Cache::clear(false)) {
         $this->success('Cake cache clear complete');
     } else {
         $this->err("Error : Cake cache clear failed");
     }
 }
Ejemplo n.º 8
0
 /**
  * Tear down method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     I18n::clear();
     I18n::defaultFormatter('default');
     I18n::locale($this->locale);
     Plugin::unload();
     Cache::clear(false, '_cake_core_');
 }
Ejemplo n.º 9
0
 /**
  * Clear a named cache.
  *
  * @return void
  * @throws \Cake\Network\Exception\NotFoundException
  */
 public function clearCache()
 {
     $this->request->allowMethod('post');
     if (!$this->request->data('name')) {
         throw new NotFoundException('Invalid cache engine name.');
     }
     $result = Cache::clear(false, $this->request->data('name'));
     $this->set(['_serialize' => ['success'], 'success' => $result]);
 }
 public function index()
 {
     //Just a way to trigger committed migrations from web interface
     echo "<pre>";
     passthru('php ../bin/cake.php migrations migrate -vvv');
     echo "</pre>";
     //Clear the Model cache so any db updates will re-load
     \Cake\Cache\Cache::clear(false, '_cake_model_');
     exit;
 }
Ejemplo n.º 11
0
 /**
  * Migrate down
  */
 public function down()
 {
     $table = $this->table('menus');
     $table->addColumn('name', 'string', ['limit' => 255, 'null' => false])->addColumn('menu_item_count', 'integer', ['default' => 0, 'null' => false])->addColumn('created', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])->addColumn('modified', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']);
     $table->addIndex('name', ['name' => 'BY_NAME', 'unique' => false]);
     $table->create();
     $id = new Column();
     $id->setIdentity(true)->setType('integer')->setOptions(['limit' => 11, 'signed' => false, 'null' => false]);
     $table->changeColumn('id', $id)->save();
     Cache::clear();
 }
Ejemplo n.º 12
0
 /**
  * Test permission with setup level and ajax request.
  *
  * @return void
  */
 public function testPermissionLevelAndAjax()
 {
     $url = array_replace($this->url, ['action' => 'permissions', 2, 0]);
     $this->_request['environment']['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     Cache::clear('permissions_aco_2', 'permissions');
     $this->get($url);
     $viewVars = $this->_controller->viewVars;
     $this->assertResponseOk();
     $this->assertInstanceOf('JBZoo\\Data\\Data', $viewVars['permissions'][3]);
     $this->assertSame('display', $viewVars['permissions'][3]->get('alias'));
     $this->assertSame(1, count($viewVars['acos']));
 }
Ejemplo n.º 13
0
 public function setUp()
 {
     parent::setUp();
     if ($this->isDebug()) {
         $this->GeoImport = new GeoImportLib();
         return;
     }
     $this->GeoImport = $this->getMock('Data\\Lib\\GeoImportLib', ['_getFromUrl']);
     $this->path = Plugin::path('Data') . 'tests' . DS . 'test_files' . DS . 'html' . DS;
     // Liste-der-St-C3-A4dte-in-der-Schweiz-action-edit-section-4.html
     Cache::clear();
 }
 /**
  * Migrate down
  */
 public function down()
 {
     $table = $this->table('menu_items');
     $table->addColumn('menu_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => false])->addColumn('parent_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => true, 'default' => null])->addColumn('lft', 'integer', ['limit' => 11, 'signed' => false, 'null' => false])->addColumn('rght', 'integer', ['limit' => 11, 'signed' => false, 'null' => false])->addColumn('name', 'string', ['limit' => 255, 'null' => false])->addColumn('type', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('target', 'text', ['null' => true, 'default' => null])->addColumn('external_link', 'text', ['null' => true, 'default' => null])->addColumn('foreign_model', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('foreign_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => true, 'default' => null])->addColumn('plugin', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('controller', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('action', 'string', ['limit' => 255, 'null' => true, 'default' => null])->addColumn('params', 'text', ['null' => true, 'default' => null])->addColumn('query', 'text', ['null' => true, 'default' => null])->addColumn('created', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])->addColumn('modified', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']);
     $table->addIndex('menu_id', ['name' => 'FK_MENU_ID', 'unique' => false]);
     $table->addIndex('parent_id', ['name' => 'FK_PARENT_ID', 'unique' => false]);
     $table->create();
     $id = new Column();
     $id->setIdentity(true)->setType('integer')->setOptions(['limit' => 11, 'signed' => false, 'null' => false]);
     $table->changeColumn('id', $id)->save();
     Cache::clear();
 }
Ejemplo n.º 15
0
 /**
  * Creates a new Query for this repository and applies some defaults based
  *  on the type of search that was selected
  * @param string $type The type of query to perform
  * @param array|ArrayAccess $options An array that will be passed to
  *  Query::applyOptions()
  * @return Cake\ORM\Query The query builder
  * @uses setNextToBePublished()
  * @uses $cache
  */
 public function find($type = 'all', $options = [])
 {
     //Gets from cache the timestamp of the next record to be published
     $next = Cache::read('next_to_be_published', $this->cache);
     //If the cache is not valid, it empties the cache
     if ($next && time() >= $next) {
         Cache::clear(false, $this->cache);
         //Sets the next record to be published
         $this->setNextToBePublished();
     }
     return parent::find($type, $options);
 }
Ejemplo n.º 16
0
 /**
  * Clear metadata.
  *
  * @param string|null $prefix The cache prefix to be cleared.
  * @throws \Cake\Console\Exception\StopException
  * @return void
  */
 public function clear($prefix = null)
 {
     try {
         $engine = Cache::engine($prefix);
         Cache::clear(false, $prefix);
         if ($engine instanceof ApcEngine) {
             $this->warn("ApcEngine detected: Cleared {$prefix} CLI cache successfully " . "but {$prefix} web cache must be cleared separately.");
         } elseif ($engine instanceof WincacheEngine) {
             $this->warn("WincacheEngine detected: Cleared {$prefix} CLI cache successfully " . "but {$prefix} web cache must be cleared separately.");
         } else {
             $this->out("<success>Cleared {$prefix} cache</success>");
         }
     } catch (\InvalidArgumentException $e) {
         $this->abort($e->getMessage());
     }
 }
Ejemplo n.º 17
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Connection = ConnectionManager::get('test');
     $this->Collection = new Collection($this->Connection);
     $this->View = new View();
     $this->Helper = new MigrationHelper($this->View, ['collection' => $this->Collection]);
     Cache::clear(false, '_cake_model_');
     Cache::enable();
     $this->loadFixtures('Users');
     $this->loadFixtures('SpecialTags');
     $this->values = ['null' => 'NULL', 'integerNull' => null, 'integerLimit' => null, 'comment' => null];
     if (getenv('DB') == 'mysql') {
         $this->values = ['null' => null, 'integerNull' => null, 'integerLimit' => 11, 'comment' => ''];
     }
     if (getenv('DB') == 'pgsql') {
         $this->values = ['null' => null, 'integerNull' => null, 'integerLimit' => 10, 'comment' => null];
     }
 }
Ejemplo n.º 18
0
 /**
  * test the clearing of cache keys
  *
  * @return void
  */
 public function testClear()
 {
     apc_store('not_cake', 'survive');
     Cache::write('some_value', 'value', 'apc');
     $result = Cache::clear(false, 'apc');
     $this->assertTrue($result);
     $this->assertFalse(Cache::read('some_value', 'apc'));
     $this->assertEquals('survive', apc_fetch('not_cake'));
     apc_delete('not_cake');
 }
Ejemplo n.º 19
0
 /**
  * testKeyPath method
  *
  * @return void
  */
 public function testKeyPath()
 {
     $result = Cache::write('views.countries.something', 'here', 'file_test');
     $this->assertTrue($result);
     $this->assertTrue(file_exists(TMP . 'tests/cake_views_countries_something'));
     $result = Cache::read('views.countries.something', 'file_test');
     $this->assertEquals('here', $result);
     $result = Cache::clear(false, 'file_test');
     $this->assertTrue($result);
     $result = Cache::write('domain.test.com:8080', 'here', 'file_test');
     $this->assertTrue($result);
     $this->assertTrue(file_exists(TMP . 'tests/cake_domain_test_com_8080'));
     $result = Cache::write('command>dir|more', 'here', 'file_test');
     $this->assertTrue($result);
     $this->assertTrue(file_exists(TMP . 'tests/cake_command_dir_more'));
 }
Ejemplo n.º 20
0
 /**
  * test the clearing of cache keys
  *
  * @return void
  */
 public function testClear()
 {
     wincache_ucache_set('not_cake', 'safe');
     Cache::write('some_value', 'value', 'wincache');
     $result = Cache::clear(false, 'wincache');
     $this->assertTrue($result);
     $this->assertFalse(Cache::read('some_value', 'wincache'));
     $this->assertEquals('safe', wincache_ucache_get('not_cake'));
 }
Ejemplo n.º 21
0
 /**
  * Test elementCache method
  *
  * @return void
  */
 public function testElementCache()
 {
     Cache::drop('test_view');
     Cache::config('test_view', ['engine' => 'File', 'duration' => '+1 day', 'path' => CACHE . 'views/', 'prefix' => '']);
     Cache::clear(false, 'test_view');
     $View = $this->PostsController->createView();
     $View->elementCache = 'test_view';
     $result = $View->element('test_element', [], ['cache' => true]);
     $expected = 'this is the test element';
     $this->assertEquals($expected, $result);
     $result = Cache::read('element__test_element_cache_callbacks', 'test_view');
     $this->assertEquals($expected, $result);
     $result = $View->element('test_element', ['param' => 'one', 'foo' => 'two'], ['cache' => true]);
     $this->assertEquals($expected, $result);
     $result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view');
     $this->assertEquals($expected, $result);
     $View->element('test_element', ['param' => 'one', 'foo' => 'two'], ['cache' => ['key' => 'custom_key']]);
     $result = Cache::read('element_custom_key', 'test_view');
     $this->assertEquals($expected, $result);
     $View->elementCache = 'default';
     $View->element('test_element', ['param' => 'one', 'foo' => 'two'], ['cache' => ['config' => 'test_view']]);
     $result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view');
     $this->assertEquals($expected, $result);
     Cache::clear(true, 'test_view');
     Cache::drop('test_view');
 }
Ejemplo n.º 22
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Acl);
     Cache::clear(false, 'tests');
     Cache::drop('tests');
 }
Ejemplo n.º 23
0
 /**
  * test clearing redis.
  *
  * @return void
  */
 public function testClear()
 {
     Cache::config('redis2', array('engine' => 'Redis', 'prefix' => 'cake2_', 'duration' => 3600));
     Cache::write('some_value', 'cache1', 'redis');
     $result = Cache::clear(true, 'redis');
     $this->assertTrue($result);
     $this->assertEquals('cache1', Cache::read('some_value', 'redis'));
     Cache::write('some_value', 'cache2', 'redis2');
     $result = Cache::clear(false, 'redis');
     $this->assertTrue($result);
     $this->assertFalse(Cache::read('some_value', 'redis'));
     $this->assertEquals('cache2', Cache::read('some_value', 'redis2'));
     Cache::clear(false, 'redis2');
 }
Ejemplo n.º 24
0
 /**
  * Clear cache of tmp folders
  *
  * @param string|null $type
  * @return bool Success
  */
 public function clearCache($type = 'default')
 {
     $config = $type;
     Cache::clear(false, $config);
     return true;
 }
Ejemplo n.º 25
0
 /**
  * Called after an entity is saved.
  *
  * @param Event $event An event instance.
  * @param Route $entity The entity that triggered the event.
  * @param ArrayObject $options Additional options passed to the save call.
  * @return void
  */
 public function afterSave(Event $event, Route $entity, ArrayObject $options)
 {
     Cache::clear(false, 'wasabi/core/routes');
     $this->eventManager()->dispatch(new Event('Wasabi.Routes.changed'));
 }
 /**
  * Clear cache.
  *
  * @return void
  */
 public function clear_cache()
 {
     $result = Cache::clear(false);
     $this->set('result', $result);
     $this->set('_serialize', ['result']);
 }
Ejemplo n.º 27
0
 /**
  * testCacheDisable method
  *
  * Check that the "Cache.disable" configuration and a change to it
  * (even after a cache config has been setup) is taken into account.
  *
  * @return void
  */
 public function testCacheDisable()
 {
     Cache::enable();
     Cache::config('test_cache_disable_1', ['engine' => 'File', 'path' => TMP . 'tests']);
     $this->assertTrue(Cache::write('key_1', 'hello', 'test_cache_disable_1'));
     $this->assertSame(Cache::read('key_1', 'test_cache_disable_1'), 'hello');
     Cache::disable();
     $this->assertNull(Cache::write('key_2', 'hello', 'test_cache_disable_1'));
     $this->assertFalse(Cache::read('key_2', 'test_cache_disable_1'));
     Cache::enable();
     $this->assertTrue(Cache::write('key_3', 'hello', 'test_cache_disable_1'));
     $this->assertSame('hello', Cache::read('key_3', 'test_cache_disable_1'));
     Cache::clear(false, 'test_cache_disable_1');
     Cache::disable();
     Cache::config('test_cache_disable_2', ['engine' => 'File', 'path' => TMP . 'tests']);
     $this->assertNull(Cache::write('key_4', 'hello', 'test_cache_disable_2'));
     $this->assertFalse(Cache::read('key_4', 'test_cache_disable_2'));
     Cache::enable();
     $this->assertTrue(Cache::write('key_5', 'hello', 'test_cache_disable_2'));
     $this->assertSame(Cache::read('key_5', 'test_cache_disable_2'), 'hello');
     Cache::disable();
     $this->assertNull(Cache::write('key_6', 'hello', 'test_cache_disable_2'));
     $this->assertFalse(Cache::read('key_6', 'test_cache_disable_2'));
     Cache::enable();
     Cache::clear(false, 'test_cache_disable_2');
 }
Ejemplo n.º 28
0
 /**
  * Clears every EAV cache.
  *
  * @return void
  */
 protected function _clearCache()
 {
     Cache::clear(false, 'eav_table_attrs');
 }
Ejemplo n.º 29
0
 /**
  * test clearing memcached.
  *
  * @return void
  */
 public function testClear()
 {
     Cache::config('memcached2', ['engine' => 'Memcached', 'prefix' => 'cake2_', 'duration' => 3600]);
     Cache::write('some_value', 'cache1', 'memcached');
     $result = Cache::clear(true, 'memcached');
     $this->assertTrue($result);
     $this->assertEquals('cache1', Cache::read('some_value', 'memcached'));
     Cache::write('some_value', 'cache2', 'memcached2');
     $result = Cache::clear(false, 'memcached');
     $this->assertTrue($result);
     $this->assertFalse(Cache::read('some_value', 'memcached'));
     $this->assertEquals('cache2', Cache::read('some_value', 'memcached2'));
     Cache::clear(false, 'memcached2');
 }
Ejemplo n.º 30
0
 /**
  * {@inheritDoc}
  */
 protected function doFlush()
 {
     return Cache::clear(false, $this->config);
 }