@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow a DAO object storage namespace to be forced to a particular value

Summary:
Ref T6703. When we import external data from a third-party install to a Phacility instance, we must link instance accounts to central accounts: either existing central accounts, or newly created central accounts that we send invites for.

During this import, or when users register and claim those new accounts, we do a write from `admin.phacility.com` directly into the instance database to link the accounts.

This is pretty sketchy, and should almost certainly just be an internal API instead, particularly now that it's relatively stable.

However, it's what we use for now. The process has had some issues since the introduction of `%R` (combined database name and table refrence in queries), and now needs to be updated for the new `providerConfigPHID` column in `ExternalAccount`.

The problem is that `%R` isn't doing the right thing. We have code like this:

```
$conn = new_connection_to_instance('turtle');
queryf($conn, 'INSERT INTO %R ...', $table);
```

However, the `$table` resolves `%R` using the currently-executing-process information, not anything specific to `$conn`, so it prints `admin_user.user_externalaccount` (the name of the table on `admin.phacility.com`, where the code is running).

We want it to print `turtle_user.user_externalaccount` instead: the name of the table on `turtle.phacility.com`, where we're actually writing.

To force this to happen, let callers override the namespace part of the database name.

Long term: I'd plan to rip this out and replace it with an API call. This "connect directly to the database" stuff is nice for iterating on (only `admin` needs hotfixes) but very very sketchy for maintaining.

Test Plan: See next diff.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T6703

Differential Revision: https://secure.phabricator.com/D20167

+13 -1
+13 -1
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
··· 6 6 abstract class PhabricatorLiskDAO extends LiskDAO { 7 7 8 8 private static $namespaceStack = array(); 9 + private $forcedNamespace; 9 10 10 11 const ATTACHABLE = '<attachable>'; 11 12 const CONFIG_APPLICATION_SERIALIZERS = 'phabricator/serializers'; ··· 45 46 throw new Exception(pht('No storage namespace configured!')); 46 47 } 47 48 return $namespace; 49 + } 50 + 51 + public function setForcedStorageNamespace($namespace) { 52 + $this->forcedNamespace = $namespace; 53 + return $this; 48 54 } 49 55 50 56 /** ··· 188 194 abstract public function getApplicationName(); 189 195 190 196 protected function getDatabaseName() { 191 - return self::getStorageNamespace().'_'.$this->getApplicationName(); 197 + if ($this->forcedNamespace) { 198 + $namespace = $this->forcedNamespace; 199 + } else { 200 + $namespace = self::getStorageNamespace(); 201 + } 202 + 203 + return $namespace.'_'.$this->getApplicationName(); 192 204 } 193 205 194 206 /**