@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.

Merge branch 'master' of github.com:facebook/phabricator

+486 -28
+8
src/__phutil_library_map__.php
··· 78 78 'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff', 79 79 'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision', 80 80 'ConduitAPI_differential_find_Method' => 'applications/conduit/method/differential/find', 81 + 'ConduitAPI_differential_getalldiffs_Method' => 'applications/conduit/method/differential/getalldiffs', 81 82 'ConduitAPI_differential_getcommitmessage_Method' => 'applications/conduit/method/differential/getcommitmessage', 82 83 'ConduitAPI_differential_getcommitpaths_Method' => 'applications/conduit/method/differential/getcommitpaths', 83 84 'ConduitAPI_differential_getdiff_Method' => 'applications/conduit/method/differential/getdiff', 85 + 'ConduitAPI_differential_getrevision_Method' => 'applications/conduit/method/differential/getrevision', 86 + 'ConduitAPI_differential_getrevisionfeedback_Method' => 'applications/conduit/method/differential/getrevisionfeedback', 84 87 'ConduitAPI_differential_markcommitted_Method' => 'applications/conduit/method/differential/markcommitted', 85 88 'ConduitAPI_differential_parsecommitmessage_Method' => 'applications/conduit/method/differential/parsecommitmessage', 86 89 'ConduitAPI_differential_setdiffproperty_Method' => 'applications/conduit/method/differential/setdiffproperty', 87 90 'ConduitAPI_differential_updaterevision_Method' => 'applications/conduit/method/differential/updaterevision', 88 91 'ConduitAPI_diffusion_getcommits_Method' => 'applications/conduit/method/diffusion/getcommits', 89 92 'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/upload', 93 + 'ConduitAPI_path_getowners_Method' => 'applications/conduit/method/path/getowners', 90 94 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', 91 95 'ConduitAPI_user_whoami_Method' => 'applications/conduit/method/user/whoami', 92 96 'ConduitException' => 'applications/conduit/protocol/exception', ··· 524 528 'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod', 525 529 'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod', 526 530 'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod', 531 + 'ConduitAPI_differential_getalldiffs_Method' => 'ConduitAPIMethod', 527 532 'ConduitAPI_differential_getcommitmessage_Method' => 'ConduitAPIMethod', 528 533 'ConduitAPI_differential_getcommitpaths_Method' => 'ConduitAPIMethod', 529 534 'ConduitAPI_differential_getdiff_Method' => 'ConduitAPIMethod', 535 + 'ConduitAPI_differential_getrevision_Method' => 'ConduitAPIMethod', 536 + 'ConduitAPI_differential_getrevisionfeedback_Method' => 'ConduitAPIMethod', 530 537 'ConduitAPI_differential_markcommitted_Method' => 'ConduitAPIMethod', 531 538 'ConduitAPI_differential_parsecommitmessage_Method' => 'ConduitAPIMethod', 532 539 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', 533 540 'ConduitAPI_differential_updaterevision_Method' => 'ConduitAPIMethod', 534 541 'ConduitAPI_diffusion_getcommits_Method' => 'ConduitAPIMethod', 535 542 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 543 + 'ConduitAPI_path_getowners_Method' => 'ConduitAPIMethod', 536 544 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', 537 545 'ConduitAPI_user_whoami_Method' => 'ConduitAPIMethod', 538 546 'DarkConsoleConfigPlugin' => 'DarkConsolePlugin',
+60
src/applications/conduit/method/differential/getalldiffs/ConduitAPI_differential_getalldiffs_Method.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class ConduitAPI_differential_getalldiffs_Method extends ConduitAPIMethod { 20 + 21 + public function getMethodDescription() { 22 + return "Load all diffs for given revisions from Differential."; 23 + } 24 + 25 + public function defineParamTypes() { 26 + return array( 27 + 'revision_ids' => 'required list<int>', 28 + ); 29 + } 30 + 31 + public function defineReturnType() { 32 + return 'dict'; 33 + } 34 + 35 + public function defineErrorTypes() { 36 + return array(); 37 + } 38 + 39 + protected function execute(ConduitAPIRequest $request) { 40 + $results = array(); 41 + $revision_ids = $request->getValue('revision_ids'); 42 + 43 + if (!$revision_ids) { 44 + return $results; 45 + } 46 + 47 + $diffs = id(new DifferentialDiff())->loadAllWhere( 48 + 'revisionID IN (%Ld)', 49 + $revision_ids); 50 + 51 + foreach ($diffs as $diff) { 52 + $results[] = array( 53 + 'revision_id' => $diff->getRevisionID(), 54 + 'diff_id' => $diff->getID(), 55 + ); 56 + } 57 + 58 + return $results; 59 + } 60 + }
+15
src/applications/conduit/method/differential/getalldiffs/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/conduit/method/base'); 10 + phutil_require_module('phabricator', 'applications/differential/storage/diff'); 11 + 12 + phutil_require_module('phutil', 'utils'); 13 + 14 + 15 + phutil_require_source('ConduitAPI_differential_getalldiffs_Method.php');
+4
src/applications/conduit/method/differential/getdiff/ConduitAPI_differential_getdiff_Method.php
··· 69 69 $changeset->attachHunks($changeset->loadHunks()); 70 70 } 71 71 72 + return $this->createDiffDict($diff); 73 + } 74 + 75 + public static function createDiffDict(DifferentialDiff $diff) { 72 76 $dict = array( 73 77 'id' => $diff->getID(), 74 78 'parent' => $diff->getParentRevisionID(),
+83
src/applications/conduit/method/differential/getrevision/ConduitAPI_differential_getrevision_Method.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class ConduitAPI_differential_getrevision_Method extends ConduitAPIMethod { 20 + 21 + public function getMethodDescription() { 22 + return "Load the content of a revision from Differential."; 23 + } 24 + 25 + public function defineParamTypes() { 26 + return array( 27 + 'revision_id' => 'required id', 28 + ); 29 + } 30 + 31 + public function defineReturnType() { 32 + return 'nonempty dict'; 33 + } 34 + 35 + public function defineErrorTypes() { 36 + return array( 37 + 'ERR_BAD_REVISION' => 'No such revision exists.', 38 + ); 39 + } 40 + 41 + protected function execute(ConduitAPIRequest $request) { 42 + $diff = null; 43 + 44 + $revision_id = $request->getValue('revision_id'); 45 + $revision = id(new DifferentialRevision())->load($revision_id); 46 + if (!$revision) { 47 + throw new ConduitException('ERR_BAD_REVISION'); 48 + } 49 + 50 + $diffs = $revision->loadDiffs(); 51 + 52 + $diff_dicts = array(); 53 + foreach ($diffs as $diff) { 54 + $diff->attachChangesets($diff->loadChangesets()); 55 + // TODO: We could batch this to improve performance. 56 + foreach ($diff->getChangesets() as $changeset) { 57 + $changeset->attachHunks($changeset->loadHunks()); 58 + } 59 + $diff_dicts[] = 60 + ConduitAPI_differential_getdiff_Method::createDiffDict($diff); 61 + } 62 + 63 + $dict = array( 64 + 'id' => $revision->getID(), 65 + 'phid' => $revision->getPHID(), 66 + 'authorPHID' => $revision->getAuthorPHID(), 67 + 'title' => $revision->getTitle(), 68 + 'status' => $revision->getStatus(), 69 + 'statusName' => DifferentialRevisionStatus::getNameForRevisionStatus( 70 + $revision->getStatus()), 71 + 'summary' => $revision->getSummary(), 72 + 'testPlan' => $revision->getTestPlan(), 73 + 'revertPlan' => $revision->getRevertPlan(), 74 + 'blameRevision' => $revision->getBlameRevision(), 75 + 'dateCommitted' => $revision->getDateCommitted(), 76 + 'lineCount' => $revision->getLineCount(), 77 + 'diffs' => $diff_dicts, 78 + ); 79 + 80 + return $dict; 81 + } 82 + 83 + }
+18
src/applications/conduit/method/differential/getrevision/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/conduit/method/base'); 10 + phutil_require_module('phabricator', 'applications/conduit/method/differential/getdiff'); 11 + phutil_require_module('phabricator', 'applications/conduit/protocol/exception'); 12 + phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus'); 13 + phutil_require_module('phabricator', 'applications/differential/storage/revision'); 14 + 15 + phutil_require_module('phutil', 'utils'); 16 + 17 + 18 + phutil_require_source('ConduitAPI_differential_getrevision_Method.php');
+72
src/applications/conduit/method/differential/getrevisionfeedback/ConduitAPI_differential_getrevisionfeedback_Method.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class ConduitAPI_differential_getrevisionfeedback_Method 20 + extends ConduitAPIMethod { 21 + 22 + public function getMethodDescription() { 23 + return "Retrieve Differential Revision Feedback."; 24 + } 25 + 26 + public function defineParamTypes() { 27 + return array( 28 + 'ids' => 'required list<int>', 29 + ); 30 + } 31 + 32 + public function defineReturnType() { 33 + return 'nonempty list<dict<string, wild>>'; 34 + } 35 + 36 + public function defineErrorTypes() { 37 + return array( 38 + ); 39 + } 40 + 41 + protected function execute(ConduitAPIRequest $request) { 42 + $results = array(); 43 + $revision_ids = $request->getValue('ids'); 44 + 45 + if (!$revision_ids) { 46 + return $results; 47 + } 48 + 49 + $comments = id(new DifferentialComment())->loadAllWhere( 50 + 'revisionID IN (%Ld)', 51 + $revision_ids); 52 + 53 + // Helper dictionary to keep track of where the id/action pair is 54 + // stored in results array. 55 + $indexes = array(); 56 + foreach ($comments as $comment) { 57 + $action = $comment->getAction(); 58 + $revision_id = $comment->getRevisionID(); 59 + 60 + if (isset($indexes[$action.$revision_id])) { 61 + $results[$indexes[$action.$revision_id]]['count']++; 62 + } else { 63 + $indexes[$action.$revision_id] = count($results); 64 + $results[] = array('id' => $revision_id, 65 + 'action' => $action, 66 + 'count' => 1); 67 + } 68 + } 69 + 70 + return $results; 71 + } 72 + }
+15
src/applications/conduit/method/differential/getrevisionfeedback/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/conduit/method/base'); 10 + phutil_require_module('phabricator', 'applications/differential/storage/comment'); 11 + 12 + phutil_require_module('phutil', 'utils'); 13 + 14 + 15 + phutil_require_source('ConduitAPI_differential_getrevisionfeedback_Method.php');
+84
src/applications/conduit/method/path/getowners/ConduitAPI_path_getowners_Method.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + class ConduitAPI_path_getowners_Method extends ConduitAPIMethod { 20 + 21 + public function getMethodDescription() { 22 + return "Find owners package given its name"; 23 + } 24 + 25 + public function defineParamTypes() { 26 + return array( 27 + 'repositoryCallsign' => 'required nonempty string', 28 + 'path' => 'required nonempty string' 29 + ); 30 + } 31 + 32 + public function defineReturnType() { 33 + return 'array of packages containing phid, primary_owner (phid=>username),'. 34 + 'owners(array of phid=>username)'; 35 + } 36 + 37 + public function defineErrorTypes() { 38 + return array( 39 + 'ERR_REP_NOT_FOUND' => 'The repository callsign is not recognized', 40 + 'ERR_PATH_NOT_FOUND' => 'The specified path is not known to any package', 41 + ); 42 + } 43 + 44 + protected function execute(ConduitAPIRequest $request) { 45 + 46 + $repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s', 47 + $request->getValue('repositoryCallsign')); 48 + 49 + if (empty($repository)) { 50 + throw new ConduitException('ERR_REP_NOT_FOUND'); 51 + } 52 + 53 + $packages = PhabricatorOwnersPackage::loadOwningPackages( 54 + $repository, $request->getValue('path')); 55 + if (empty($packages)) { 56 + throw new ConduitException('ERR_PATH_NOT_FOUND'); 57 + } 58 + 59 + $owner = new PhabricatorOwnersOwner(); 60 + $user = new PhabricatorUser(); 61 + $result = array(); 62 + foreach ($packages as $package) { 63 + $p_result = array(); 64 + $p_result['phid'] = $package->getID(); 65 + $primary_owner_phid = $package->getPrimaryOwnerPHID(); 66 + if (!empty($primary_owner_phid)) { 67 + $p_user = $user->loadOneWhere('phid = %s', 68 + $primary_owner_phid); 69 + $p_result['primaryOwner'] = $p_user->getPhid(); 70 + } 71 + 72 + $p_owners = $owner->loadAllForPackages(array($package)); 73 + $p_users = $user->loadAllWhere('phid IN (%Ls)', 74 + mpull($p_owners, 'getUserPHID')); 75 + 76 + $p_result['owners'] = array_values(mpull($p_users, 'getPhid')); 77 + 78 + $result[] = $p_result; 79 + } 80 + 81 + return $result; 82 + } 83 + 84 + }
+19
src/applications/conduit/method/path/getowners/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/conduit/method/base'); 10 + phutil_require_module('phabricator', 'applications/conduit/protocol/exception'); 11 + phutil_require_module('phabricator', 'applications/owners/storage/owner'); 12 + phutil_require_module('phabricator', 'applications/owners/storage/package'); 13 + phutil_require_module('phabricator', 'applications/people/storage/user'); 14 + phutil_require_module('phabricator', 'applications/repository/storage/repository'); 15 + 16 + phutil_require_module('phutil', 'utils'); 17 + 18 + 19 + phutil_require_source('ConduitAPI_path_getowners_Method.php');
+1
src/applications/differential/controller/changesetview/DifferentialChangesetViewController.php
··· 132 132 $parser->setChangeset($changeset); 133 133 $parser->setRightSideCommentMapping($right_source, $right_new); 134 134 $parser->setLeftSideCommentMapping($left_source, $left_new); 135 + $parser->setWhitespaceMode($request->getStr('whitespace')); 135 136 136 137 $phids = array(); 137 138 $inlines = $this->loadInlineComments($id, $author_phid);
+4 -4
src/applications/differential/controller/inlinecommentedit/DifferentialInlineCommentEditController.php
··· 70 70 71 71 if ($request->isFormPost()) { 72 72 $inline->delete(); 73 - return $this->buildDeletedResponse(); 73 + return $this->buildEmptyResponse(); 74 74 } 75 75 76 76 $edit_dialog->setTitle('Really delete this comment?'); ··· 95 95 $on_right); 96 96 } else { 97 97 $inline->delete(); 98 - return $this->buildDeletedResponse(); 98 + return $this->buildEmptyResponse(); 99 99 } 100 100 } 101 101 ··· 112 112 case 'create': 113 113 114 114 if (!$request->isFormPost() || !strlen($text)) { 115 - return new AphrontAjaxResponse(); 115 + return $this->buildEmptyResponse(); 116 116 } 117 117 118 118 $inline = id(new DifferentialInlineComment()) ··· 173 173 )); 174 174 } 175 175 176 - private function buildDeletedResponse() { 176 + private function buildEmptyResponse() { 177 177 return id(new AphrontAjaxResponse()) 178 178 ->setContent( 179 179 array(
+2
src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php
··· 173 173 $diff_history->setDiffs($diffs); 174 174 $diff_history->setSelectedVersusDiffID($diff_vs); 175 175 $diff_history->setSelectedDiffID($target->getID()); 176 + $diff_history->setSelectedWhitespace($request->getStr('whitespace')); 176 177 177 178 $toc_view = new DifferentialDiffTableOfContentsView(); 178 179 $toc_view->setChangesets($changesets); ··· 185 186 $changeset_view->setEditable(true); 186 187 $changeset_view->setRevision($revision); 187 188 $changeset_view->setVsMap($vs_map); 189 + $changeset_view->setWhitespace($request->getStr('whitespace')); 188 190 189 191 $draft = id(new PhabricatorDraft())->loadOneWhere( 190 192 'authorPHID = %s AND draftKey = %s',
+2 -2
src/applications/differential/parser/changeset/DifferentialChangesetParser.php
··· 675 675 676 676 $diff = DifferentialDiff::newFromRawChanges($changes); 677 677 $changesets = $diff->getChangesets(); 678 - $alt_changeset = reset($changesets); 678 + $changeset = reset($changesets); 679 679 680 680 $this->subparser = new DifferentialChangesetParser(); 681 - $this->subparser->setChangeset($alt_changeset); 681 + $this->subparser->setChangeset($changeset); 682 682 $this->subparser->setWhitespaceMode(self::WHITESPACE_IGNORE_TRAILING); 683 683 } 684 684 foreach ($changeset->getHunks() as $hunk) {
+8 -3
src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php
··· 23 23 private $revision; 24 24 private $renderURI = '/differential/changeset/'; 25 25 private $vsMap = array(); 26 + private $whitespace = null; 26 27 27 28 public function setChangesets($changesets) { 28 29 $this->changesets = $changesets; ··· 46 47 47 48 public function setRenderURI($render_uri) { 48 49 $this->renderURI = $render_uri; 50 + return $this; 51 + } 52 + 53 + public function setWhitespace($whitespace) { 54 + $this->whitespace = $whitespace; 49 55 return $this; 50 56 } 51 57 ··· 77 83 array( 78 84 'id' => $ref, 79 85 'vs' => $vs_id, 80 - 'whitespace' => 'TODO', 86 + 'whitespace' => $this->whitespace, 81 87 )); 82 88 83 89 $detail_button = phutil_render_tag( ··· 109 115 $vs_id); 110 116 } 111 117 112 - $whitespace = null; 113 118 Javelin::initBehavior('differential-populate', array( 114 119 'registry' => $mapping, 115 - 'whitespace' => $whitespace, 120 + 'whitespace' => $this->whitespace, 116 121 'uri' => $this->renderURI, 117 122 )); 118 123
+25 -1
src/applications/differential/view/revisionupdatehistory/DifferentialRevisionUpdateHistoryView.php
··· 21 21 private $diffs = array(); 22 22 private $selectedVersusDiffID; 23 23 private $selectedDiffID; 24 + private $selectedWhitespace; 24 25 25 26 public function setDiffs($diffs) { 26 27 $this->diffs = $diffs; ··· 34 35 35 36 public function setSelectedDiffID($id) { 36 37 $this->selectedDiffID = $id; 38 + return $this; 39 + } 40 + 41 + public function setSelectedWhitespace($whitespace) { 42 + $this->selectedWhitespace = $whitespace; 37 43 return $this; 38 44 } 39 45 ··· 157 163 'radios' => $radios, 158 164 )); 159 165 160 - $select = '<select><option>Ignore All</option></select>'; 166 + $options = array( 167 + 'ignore-all' => 'Ignore All', 168 + 'ignore-trailing' => 'Ignore Trailing', 169 + 'show-all' => 'Show All', 170 + ); 171 + 172 + $select = '<select name="whitespace">'; 173 + foreach ($options as $value => $label) { 174 + $select .= phutil_render_tag( 175 + 'option', 176 + array( 177 + 'value' => $value, 178 + 'selected' => ($value == $this->selectedWhitespace) 179 + ? 'selected' 180 + : null, 181 + ), 182 + phutil_escape_html($label)); 183 + } 184 + $select .= '</select>'; 161 185 162 186 return 163 187 '<div class="differential-revision-history differential-panel">'.
+63 -15
src/applications/owners/storage/package/PhabricatorOwnersPackage.php
··· 79 79 ); 80 80 81 81 foreach ($paths as $path) { 82 - $trailing_slash = preg_match('@/$@', $path) ? '/' : ''; 83 - $path = trim($path, '/'); 84 - $parts = explode('/', $path); 85 - while (count($parts)) { 86 - $fragments['/'.implode('/', $parts).$trailing_slash] = true; 87 - $trailing_slash = '/'; 88 - array_pop($parts); 89 - } 82 + $fragments += self::splitPath($path); 90 83 } 91 84 85 + return self::loadPackagesForPaths($repository, array_keys($fragments)); 86 + } 87 + 88 + public static function loadOwningPackages($repository, $path) { 89 + if (empty($path)) { 90 + return array(); 91 + } 92 + 93 + $fragments = self::splitPath($path); 94 + return self::loadPackagesForPaths($repository, array_keys($fragments), 1); 95 + } 96 + 97 + private static function loadPackagesForPaths( 98 + PhabricatorRepository $repository, 99 + array $paths, 100 + $limit = 0) { 92 101 $package = new PhabricatorOwnersPackage(); 93 102 $path = new PhabricatorOwnersPath(); 103 + $conn = $package->establishConnection('r'); 104 + 105 + $repository_clause = qsprintf($conn, 'AND p.repositoryPHID = %s', 106 + $repository->getPHID()); 107 + 108 + $limit_clause = ''; 109 + if (!empty($limit)) { 110 + $limit_clause = qsprintf($conn, 'LIMIT %d', $limit); 111 + } 112 + 94 113 $data = queryfx_all( 95 - $package->establishConnection('r'), 96 - 'SELECT pkg.* FROM %T pkg JOIN %T p ON p.packageID = pkg.id 97 - WHERE p.repositoryPHID = %s 98 - AND p.path IN (%Ls)', 114 + $conn, 115 + 'SELECT pkg.id FROM %T pkg JOIN %T p ON p.packageID = pkg.id 116 + WHERE p.path IN (%Ls) %Q ORDER BY LENGTH(p.path) DESC %Q', 99 117 $package->getTableName(), 100 118 $path->getTableName(), 101 - $repository->getPHID(), 102 - array_keys($fragments)); 119 + $paths, 120 + $repository_clause, 121 + $limit_clause); 122 + 123 + $ids = ipull($data, 'id'); 124 + 125 + if (empty($ids)) { 126 + return array(); 127 + } 128 + 129 + $order = array(); 130 + foreach ($ids as $id) { 131 + if (empty($order[$id])) { 132 + $order[$id] = true; 133 + } 134 + } 135 + 136 + $packages = $package->loadAllWhere('id in (%Ld)', array_keys($order)); 103 137 104 - return $package->loadAllFromArray($data); 138 + $packages = array_select_keys($packages, array_keys($order)); 139 + 140 + return $packages; 105 141 } 106 142 107 143 public function save() { ··· 167 203 return parent::delete(); 168 204 } 169 205 206 + private static function splitPath($path) { 207 + $result = array(); 208 + $trailing_slash = preg_match('@/$@', $path) ? '/' : ''; 209 + $path = trim($path, '/'); 210 + $parts = explode('/', $path); 211 + while (count($parts)) { 212 + $result['/'.implode('/', $parts).$trailing_slash] = true; 213 + $trailing_slash = '/'; 214 + array_pop($parts); 215 + } 216 + return $result; 217 + } 170 218 }
+1
src/applications/owners/storage/package/__init__.php
··· 10 10 phutil_require_module('phabricator', 'applications/owners/storage/owner'); 11 11 phutil_require_module('phabricator', 'applications/owners/storage/path'); 12 12 phutil_require_module('phabricator', 'applications/phid/storage/phid'); 13 + phutil_require_module('phabricator', 'storage/qsprintf'); 13 14 phutil_require_module('phabricator', 'storage/queryfx'); 14 15 15 16 phutil_require_module('phutil', 'utils');
+2 -3
src/infrastructure/markup/remarkup/markuprule/imagemacro/PhabricatorRemarkupRuleImageMacro.php
··· 32 32 $this->images[$row->getName()] = $row->getFilePHID(); 33 33 } 34 34 $this->images[self::RANDOM_IMAGE_NAME] = ''; 35 + $this->hash = 0; 35 36 } 36 37 37 38 public function apply($text) { 38 - $this->hash = 0; 39 - 40 39 return preg_replace_callback( 41 - '@\b([a-zA-Z0-9_\-]+)\b@U', 40 + '@\b([a-zA-Z0-9_\-]+)\b@', 42 41 array($this, 'markupImageMacro'), 43 42 $text); 44 43 }