Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / storage / PhabricatorRepositoryURIIndex.php
blob3ef41f80898e92336e5408721763648c672ec109
1 <?php
3 final class PhabricatorRepositoryURIIndex
4 extends PhabricatorRepositoryDAO {
6 protected $repositoryPHID;
7 protected $repositoryURI;
9 protected function getConfiguration() {
10 return array(
11 self::CONFIG_TIMESTAMPS => false,
12 self::CONFIG_COLUMN_SCHEMA => array(
13 'repositoryURI' => 'text',
15 self::CONFIG_KEY_SCHEMA => array(
16 'key_repository' => array(
17 'columns' => array('repositoryPHID'),
19 'key_uri' => array(
20 'columns' => array('repositoryURI(128)'),
23 ) + parent::getConfiguration();
26 public static function updateRepositoryURIs(
27 $repository_phid,
28 array $uris) {
30 $table = new self();
31 $conn_w = $table->establishConnection('w');
33 $sql = array();
34 foreach ($uris as $key => $uri) {
35 if (!strlen($uri)) {
36 unset($uris[$key]);
37 continue;
40 $sql[] = qsprintf(
41 $conn_w,
42 '(%s, %s)',
43 $repository_phid,
44 $uri);
47 $table->openTransaction();
49 queryfx(
50 $conn_w,
51 'DELETE FROM %R WHERE repositoryPHID = %s',
52 $table,
53 $repository_phid);
55 if ($sql) {
56 queryfx(
57 $conn_w,
58 'INSERT INTO %R (repositoryPHID, repositoryURI) VALUES %LQ',
59 $table,
60 $sql);
63 $table->saveTransaction();