Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15442131
D17029.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D17029.diff
View Options
diff --git a/src/applications/policy/rule/PhabricatorPolicyRule.php b/src/applications/policy/rule/PhabricatorPolicyRule.php
--- a/src/applications/policy/rule/PhabricatorPolicyRule.php
+++ b/src/applications/policy/rule/PhabricatorPolicyRule.php
@@ -144,9 +144,30 @@
private static function getObjectPolicyCacheKey(
PhabricatorPolicyInterface $object,
PhabricatorPolicyRule $rule) {
- $hash = spl_object_hash($object);
- $rule = get_class($rule);
- return 'policycache.'.$hash.'.'.$rule;
+
+ // NOTE: This is quite a bit of a hack, but we don't currently have a
+ // better way to carry hints from the TransactionEditor into PolicyRules
+ // about pending policy changes.
+
+ // Put some magic secret unique value on each object so we can pass
+ // information about it by proxy. This allows us to test if pending
+ // edits to an object will cause policy violations or not, before allowing
+ // those edits to go through.
+
+ // Some better approaches might be:
+ // - Use traits to give `PhabricatorPolicyInterface` objects real
+ // storage (requires PHP 5.4.0).
+ // - Wrap policy objects in a container with extra storage which the
+ // policy filter knows how to unbox (lots of work).
+
+ // When this eventually gets cleaned up, the corresponding hack in
+ // LiskDAO->__set() should also be cleaned up.
+ static $id = 0;
+ if (!isset($object->_hashKey)) {
+ @$object->_hashKey = 'object.id('.(++$id).')';
+ }
+
+ return $object->_hashKey;
}
diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php
--- a/src/infrastructure/storage/lisk/LiskDAO.php
+++ b/src/infrastructure/storage/lisk/LiskDAO.php
@@ -1780,10 +1780,13 @@
* @task util
*/
public function __set($name, $value) {
- phlog(
- pht(
- 'Wrote to undeclared property %s.',
- get_class($this).'::$'.$name));
+ // Hack for policy system hints, see PhabricatorPolicyRule for notes.
+ if ($name != '_hashKey') {
+ phlog(
+ pht(
+ 'Wrote to undeclared property %s.',
+ get_class($this).'::$'.$name));
+ }
$this->$name = $value;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 27, 9:42 PM (5 d, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7383711
Default Alt Text
D17029.diff (2 KB)
Attached To
Mode
D17029: Fix flaky subscribers policy rule unit test
Attached
Detach File
Event Timeline
Log In to Comment