protected function collectGarbage() { $session_table = new PhabricatorAuthSession(); $conn_w = $session_table->establishConnection('w'); queryfx($conn_w, 'DELETE FROM %T WHERE sessionExpires <= UNIX_TIMESTAMP() LIMIT 100', $session_table->getTableName()); return $conn_w->getAffectedRows() == 100; }
protected function loadPage() { $table = new PhabricatorAuthSession(); $conn_r = $table->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); return $table->loadAllFromArray($data); }
/** * Strip the high security flag from a session. * * Kicks a session out of high security and logs the exit. * * @param PhabricatorUser Acting user. * @param PhabricatorAuthSession Session to return to normal security. * @return void * @task hisec */ public function exitHighSecurity(PhabricatorUser $viewer, PhabricatorAuthSession $session) { if (!$session->getHighSecurityUntil()) { return; } queryfx($session->establishConnection('w'), 'UPDATE %T SET highSecurityUntil = NULL WHERE id = %d', $session->getTableName(), $session->getID()); $log = PhabricatorUserLog::initializeNewLog($viewer, $viewer->getPHID(), PhabricatorUserLog::ACTION_EXIT_HISEC); $log->save(); }
protected function applyCustomExternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { switch ($xaction->getTransactionType()) { case LegalpadTransaction::TYPE_REQUIRE_SIGNATURE: if ($xaction->getNewValue()) { $session = new PhabricatorAuthSession(); queryfx($session->establishConnection('w'), 'UPDATE %T SET signedLegalpadDocuments = 0', $session->getTableName()); } break; } return; }
<?php // Prior to this patch, we issued sessions "web-1", "web-2", etc., up to some // limit. This collapses all the "web-X" sessions into "web" sessions. $session_table = new PhabricatorAuthSession(); $conn_w = $session_table->establishConnection('w'); foreach (new LiskMigrationIterator($session_table) as $session) { $id = $session->getID(); echo "Migrating session {$id}...\n"; $old_type = $session->getType(); $new_type = preg_replace('/-.*$/', '', $old_type); if ($old_type !== $new_type) { queryfx($conn_w, 'UPDATE %T SET type = %s WHERE id = %d', $session_table->getTableName(), $new_type, $id); } } echo "Done.\n";