public static function updateHint($repository_phid, $old, $new, $type) { switch ($type) { case self::HINT_NONE: break; case self::HINT_REWRITTEN: if (!$new) { throw new Exception(pht('When hinting a commit ("%s") as rewritten, you must provide ' . 'the commit it was rewritten into.', $old)); } break; case self::HINT_UNREADABLE: if ($new) { throw new Exception(pht('When hinting a commit ("%s") as unreadable, you must not ' . 'provide a new commit ("%s").', $old, $new)); } break; default: $all_types = self::getAllHintTypes(); throw new Exception(pht('Hint type ("%s") for commit ("%s") is not valid. Valid hints ' . 'are: %s.', $type, $old, implode(', ', $all_types))); } $table = new self(); $table_name = $table->getTableName(); $conn = $table->establishConnection('w'); if ($type == self::HINT_NONE) { queryfx($conn, 'DELETE FROM %T WHERE repositoryPHID = %s AND oldCommitIdentifier = %s', $table_name, $repository_phid, $old); } else { queryfx($conn, 'INSERT INTO %T (repositoryPHID, oldCommitIdentifier, newCommitIdentifier, hintType) VALUES (%s, %s, %ns, %s) ON DUPLICATE KEY UPDATE newCommitIdentifier = VALUES(newCommitIdentifier), hintType = VALUES(hintType)', $table_name, $repository_phid, $old, $new, $type); } }
public static function clearCacheForAllUsers($key) { if (PhabricatorEnv::isReadOnly()) { return; } $table = new self(); $conn_w = $table->establishConnection('w'); $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); queryfx($conn_w, 'DELETE FROM %T WHERE cacheIndex = %s', $table->getTableName(), PhabricatorHash::digestForIndex($key)); unset($unguarded); }
public static function updateRepositoryURIs($repository_phid, array $uris) { $table = new self(); $conn_w = $table->establishConnection('w'); $sql = array(); foreach ($uris as $key => $uri) { if (!strlen($uri)) { unset($uris[$key]); continue; } $sql[] = qsprintf($conn_w, '(%s, %s)', $repository_phid, $uri); } $table->openTransaction(); queryfx($conn_w, 'DELETE FROM %T WHERE repositoryPHID = %s', $table->getTableName(), $repository_phid); if ($sql) { queryfx($conn_w, 'INSERT INTO %T (repositoryPHID, repositoryURI) VALUES %Q', $table->getTableName(), implode(', ', $sql)); } $table->saveTransaction(); }
/** * Explicitly demote a device. */ public static function demoteDevice($repository_phid, $device_phid) { $version = new self(); $conn_w = $version->establishConnection('w'); $table = $version->getTableName(); queryfx($conn_w, 'DELETE FROM %T WHERE repositoryPHID = %s AND devicePHID = %s', $table, $repository_phid, $device_phid); }