コード例 #1
0
ファイル: TestCase.php プロジェクト: elgg/elgg
 /**
  * Bootstraps test suite
  *
  * @global stdClass $CONFIG Global config
  * @global stdClass $_ELGG  Global vars
  * @return void
  */
 public static function bootstrap()
 {
     date_default_timezone_set('America/Los_Angeles');
     error_reporting(E_ALL | E_STRICT);
     $config = new Config((object) self::getTestingConfigArray());
     $sp = new ServiceProvider($config);
     $sp->setFactory('plugins', function (ServiceProvider $c) {
         $pool = new InMemory();
         return new TestingPlugins($pool, $c->pluginSettingsCache);
     });
     $sp->setValue('mailer', new InMemoryTransport());
     $sp->siteSecret->setTestingSecret('z1234567890123456789012345678901');
     // persistentLogin service needs this set to instantiate without calling DB
     $sp->config->getCookieConfig();
     $app = new Application($sp);
     Application::setTestingApplication(true);
     Application::$_instance = $app;
     // loadCore bails on repeated calls, so we need to manually inject this to make
     // sure it happens before each test.
     $app->loadCore();
     _elgg_services($sp);
     // Invalidate memcache
     _elgg_get_memcache('new_entity_cache')->clear();
     self::$_mocks = null;
     // reset mocking service
 }
コード例 #2
0
ファイル: ElggEntity.php プロジェクト: elgg/elgg
 /**
  * Update the last_action column in the entities table.
  *
  * @warning This is different to time_updated.  Time_updated is automatically set,
  * while last_action is only set when explicitly called.
  *
  * @param int $posted Timestamp of last action
  * @return int|false
  * @access private
  */
 public function updateLastAction($posted = null)
 {
     $posted = _elgg_services()->entityTable->updateLastAction($this, $posted);
     if ($posted) {
         $this->attributes['last_action'] = $posted;
         _elgg_services()->entityCache->set($this);
         $this->storeInPersistedCache(_elgg_get_memcache('new_entity_cache'));
     }
     return $posted;
 }
コード例 #3
0
ファイル: memcache.php プロジェクト: elgg/elgg
/**
 * Invalidate an entity in memcache
 *
 * @param int $entity_guid The GUID of the entity to invalidate
 *
 * @return void
 * @access private
 */
function _elgg_invalidate_memcache_for_entity($entity_guid)
{
    _elgg_get_memcache('new_entity_cache')->delete($entity_guid);
}
コード例 #4
0
ファイル: UsersTable.php プロジェクト: elgg/elgg
 /**
  * Sets the last logon time of the given user to right now.
  *
  * @param ElggUser $user User entity
  * @return void
  */
 public function setLastLogin(ElggUser $user)
 {
     $time = $this->getCurrentTime()->getTimestamp();
     if ($user->last_login == $time) {
         // no change required
         return;
     }
     $query = "\n\t\t\tUPDATE {$this->table}\n\t\t\tSET\n\t\t\t\tprev_last_login = last_login,\n\t\t\t\tlast_login = :last_login\n\t\t\tWHERE guid = :guid\n\t\t";
     $params = [':last_login' => $time, ':guid' => (int) $user->guid];
     $user->prev_last_login = $user->last_login;
     $user->last_login = $time;
     execute_delayed_write_query($query, null, $params);
     $this->entity_cache->set($user);
     // If we save the user to memcache during this request, then we'll end up with the
     // old (incorrect) attributes cached. Hence we want to invalidate as late as possible.
     // the user object gets saved
     register_shutdown_function(function () use($user) {
         $user->storeInPersistedCache(_elgg_get_memcache('new_entity_cache'));
     });
 }
コード例 #5
0
ファイル: EntityTable.php プロジェクト: elgg/elgg
 /**
  * Update the last_action column in the entities table for $guid.
  *
  * @warning This is different to time_updated.  Time_updated is automatically set,
  * while last_action is only set when explicitly called.
  *
  * @param ElggEntity $entity Entity annotation|relationship action carried out on
  * @param int        $posted Timestamp of last action
  * @return int|false
  * @access private
  */
 public function updateLastAction(ElggEntity $entity, $posted = null)
 {
     if (!$posted) {
         $posted = $this->getCurrentTime()->getTimestamp();
     }
     $query = "\n\t\t\tUPDATE {$this->db->prefix}entities\n\t\t\tSET last_action = :last_action\n\t\t\tWHERE guid = :guid\n\t\t";
     $params = [':last_action' => (int) $posted, ':guid' => (int) $entity->guid];
     $result = $this->db->updateData($query, true, $params);
     if ($result) {
         $entity->last_action = $posted;
         _elgg_services()->entityCache->set($entity);
         $entity->storeInPersistedCache(_elgg_get_memcache('new_entity_cache'));
         return (int) $posted;
     }
     return false;
 }