From 79154455437be1210b36dab1939b24e0a06c8fb9 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 29 Mar 2018 11:22:02 -0700 Subject: [PATCH] Fix two issues with Differential updates and Owners Summary: Ref T13114. - Followup fix for D19267, which didn't work correctly with //new// revision creation. - Followup fix for changes in T11015. Some of the querying logic was still handling "/x.y" and "/x.y/" differently. Instead, normalize consistently to "/x.y/" Test Plan: - Created a new revision cleanly. - Created a package owning only a `example.txt` file and saw Differential find it as an owning package in the table of contents. Maniphest Tasks: T13114 Differential Revision: https://secure.phabricator.com/D19268 --- .../DifferentialRevisionUpdateTransaction.php | 4 +++- .../storage/PhabricatorOwnersPackage.php | 21 +++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/applications/differential/xaction/DifferentialRevisionUpdateTransaction.php b/src/applications/differential/xaction/DifferentialRevisionUpdateTransaction.php index 2b74cbfab5..189ed2f2ba 100644 --- a/src/applications/differential/xaction/DifferentialRevisionUpdateTransaction.php +++ b/src/applications/differential/xaction/DifferentialRevisionUpdateTransaction.php @@ -137,7 +137,9 @@ final class DifferentialRevisionUpdateTransaction continue; } - $is_attached = ($diff->getRevisionID() == $object->getID()); + $is_attached = + ($diff->getRevisionID()) && + ($diff->getRevisionID() == $object->getID()); if ($is_attached) { $is_active = ($diff_phid == $object->getActiveDiffPHID()); } else { diff --git a/src/applications/owners/storage/PhabricatorOwnersPackage.php b/src/applications/owners/storage/PhabricatorOwnersPackage.php index 56dd51a3c6..c76864702c 100644 --- a/src/applications/owners/storage/PhabricatorOwnersPackage.php +++ b/src/applications/owners/storage/PhabricatorOwnersPackage.php @@ -393,19 +393,22 @@ final class PhabricatorOwnersPackage } public static function splitPath($path) { - $trailing_slash = preg_match('@/$@', $path) ? '/' : ''; - $path = trim($path, '/'); + $result = array( + '/', + ); + $parts = explode('/', $path); + $buffer = '/'; + foreach ($parts as $part) { + if (!strlen($part)) { + continue; + } - $result = array(); - while (count($parts)) { - $result[] = '/'.implode('/', $parts).$trailing_slash; - $trailing_slash = '/'; - array_pop($parts); + $buffer = $buffer.$part.'/'; + $result[] = $buffer; } - $result[] = '/'; - return array_reverse($result); + return $result; } public function attachPaths(array $paths) {