@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

Replace "URI->setQueryParams()" after initialization with a constructor argument

Summary: Ref T13250. See D20149. In a number of cases, we use `setQueryParams()` immediately after URI construction. To simplify this slightly, let the constructor take parameters, similar to `HTTPSFuture`.

Test Plan: See inlines.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13250

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

+83 -92
+6 -12
src/applications/almanac/controller/AlmanacController.php
··· 67 67 $is_builtin = isset($builtins[$key]); 68 68 $is_persistent = (bool)$property->getID(); 69 69 70 - $delete_uri = id(new PhutilURI($delete_base)) 71 - ->setQueryParams( 72 - array( 73 - 'key' => $key, 74 - 'objectPHID' => $object->getPHID(), 75 - )); 70 + $params = array( 71 + 'key' => $key, 72 + 'objectPHID' => $object->getPHID(), 73 + ); 76 74 77 - $edit_uri = id(new PhutilURI($edit_base)) 78 - ->setQueryParams( 79 - array( 80 - 'key' => $key, 81 - 'objectPHID' => $object->getPHID(), 82 - )); 75 + $delete_uri = new PhutilURI($delete_base, $params); 76 + $edit_uri = new PhutilURI($edit_base, $params); 83 77 84 78 $delete = javelin_tag( 85 79 'a',
+5 -5
src/applications/auth/controller/PhabricatorAuthOneTimeLoginController.php
··· 218 218 219 219 $request->setTemporaryCookie(PhabricatorCookies::COOKIE_HISEC, 'yes'); 220 220 221 - return (string)id(new PhutilURI($panel_uri)) 222 - ->setQueryParams( 223 - array( 224 - 'key' => $key, 225 - )); 221 + $params = array( 222 + 'key' => $key, 223 + ); 224 + 225 + return (string)new PhutilURI($panel_uri, $params); 226 226 } 227 227 228 228 $providers = id(new PhabricatorAuthProviderConfigQuery())
+11 -8
src/applications/auth/future/PhabricatorDuoFuture.php
··· 80 80 $host = $this->apiHostname; 81 81 $host = phutil_utf8_strtolower($host); 82 82 83 - $uri = id(new PhutilURI('')) 84 - ->setProtocol('https') 85 - ->setDomain($host) 86 - ->setPath($path); 87 - 88 83 $data = $this->parameters; 89 84 $date = date('r'); 90 85 ··· 109 104 $signature = new PhutilOpaqueEnvelope($signature); 110 105 111 106 if ($http_method === 'GET') { 112 - $uri->setQueryParams($data); 113 - $data = array(); 107 + $uri_data = $data; 108 + $body_data = array(); 109 + } else { 110 + $uri_data = array(); 111 + $body_data = $data; 114 112 } 115 113 116 - $future = id(new HTTPSFuture($uri, $data)) 114 + $uri = id(new PhutilURI('', $uri_data)) 115 + ->setProtocol('https') 116 + ->setDomain($host) 117 + ->setPath($path); 118 + 119 + $future = id(new HTTPSFuture($uri, $body_data)) 117 120 ->setHTTPBasicAuthCredentials($this->integrationKey, $signature) 118 121 ->setMethod($http_method) 119 122 ->addHeader('Accept', 'application/json')
+6 -6
src/applications/diffusion/view/DiffusionView.php
··· 81 81 } 82 82 83 83 if (isset($details['external'])) { 84 - $href = id(new PhutilURI('/diffusion/external/')) 85 - ->setQueryParams( 86 - array( 87 - 'uri' => idx($details, 'external'), 88 - 'id' => idx($details, 'hash'), 89 - )); 84 + $params = array( 85 + 'uri' => idx($details, 'external'), 86 + 'id' => idx($details, 'hash'), 87 + ); 88 + 89 + $href = new PhutilURI('/diffusion/external/', $params); 90 90 $tip = pht('Browse External'); 91 91 } else { 92 92 $href = $this->getDiffusionRequest()->generateURI(
+9 -9
src/applications/diviner/markup/DivinerSymbolRemarkupRule.php
··· 111 111 // Here, we're generating comment text or something like that. Just 112 112 // link to Diviner and let it sort things out. 113 113 114 - $href = id(new PhutilURI('/diviner/find/')) 115 - ->setQueryParams( 116 - array( 117 - 'book' => $ref->getBook(), 118 - 'name' => $ref->getName(), 119 - 'type' => $ref->getType(), 120 - 'context' => $ref->getContext(), 121 - 'jump' => true, 122 - )); 114 + $params = array( 115 + 'book' => $ref->getBook(), 116 + 'name' => $ref->getName(), 117 + 'type' => $ref->getType(), 118 + 'context' => $ref->getContext(), 119 + 'jump' => true, 120 + ); 121 + 122 + $href = new PhutilURI('/diviner/find/', $params); 123 123 } 124 124 125 125 // TODO: This probably is not the best place to do this. Move it somewhere
+20 -20
src/applications/herald/controller/HeraldNewController.php
··· 81 81 } 82 82 83 83 if (!$errors && $done) { 84 - $uri = id(new PhutilURI('edit/')) 85 - ->setQueryParams( 86 - array( 87 - 'content_type' => $content_type, 88 - 'rule_type' => $rule_type, 89 - 'targetPHID' => $target_phid, 90 - )); 84 + $params = array( 85 + 'content_type' => $content_type, 86 + 'rule_type' => $rule_type, 87 + 'targetPHID' => $target_phid, 88 + ); 89 + 90 + $uri = new PhutilURI('edit/', $params); 91 91 $uri = $this->getApplicationURI($uri); 92 92 return id(new AphrontRedirectResponse())->setURI($uri); 93 93 } ··· 126 126 ->addHiddenInput('step', 2) 127 127 ->appendChild($rule_types); 128 128 129 + $params = array( 130 + 'content_type' => $content_type, 131 + 'step' => '0', 132 + ); 133 + 129 134 $cancel_text = pht('Back'); 130 - $cancel_uri = id(new PhutilURI('new/')) 131 - ->setQueryParams( 132 - array( 133 - 'content_type' => $content_type, 134 - 'step' => 0, 135 - )); 135 + $cancel_uri = new PhutilURI('new/', $params); 136 136 $cancel_uri = $this->getApplicationURI($cancel_uri); 137 137 $title = pht('Create Herald Rule: %s', 138 138 idx($content_type_map, $content_type)); ··· 173 173 ->setValue($request->getStr('objectName')) 174 174 ->setLabel(pht('Object'))); 175 175 176 + $params = array( 177 + 'content_type' => $content_type, 178 + 'rule_type' => $rule_type, 179 + 'step' => 1, 180 + ); 181 + 176 182 $cancel_text = pht('Back'); 177 - $cancel_uri = id(new PhutilURI('new/')) 178 - ->setQueryParams( 179 - array( 180 - 'content_type' => $content_type, 181 - 'rule_type' => $rule_type, 182 - 'step' => 1, 183 - )); 183 + $cancel_uri = new PhutilURI('new/', $params); 184 184 $cancel_uri = $this->getApplicationURI($cancel_uri); 185 185 $title = pht('Create Herald Rule: %s', 186 186 idx($content_type_map, $content_type));
+5 -5
src/applications/owners/controller/PhabricatorOwnersDetailController.php
··· 65 65 66 66 $commit_views = array(); 67 67 68 - $commit_uri = id(new PhutilURI('/diffusion/commit/')) 69 - ->setQueryParams( 70 - array( 71 - 'package' => $package->getPHID(), 72 - )); 68 + $params = array( 69 + 'package' => $package->getPHID(), 70 + ); 71 + 72 + $commit_uri = new PhutilURI('/diffusion/commit/', $params); 73 73 74 74 $status_concern = DiffusionCommitAuditStatus::CONCERN_RAISED; 75 75
+6 -6
src/applications/phortune/controller/cart/PhortuneCartCheckoutController.php
··· 134 134 135 135 $account_id = $account->getID(); 136 136 137 + $params = array( 138 + 'merchantID' => $merchant->getID(), 139 + 'cartID' => $cart->getID(), 140 + ); 141 + 137 142 $payment_method_uri = $this->getApplicationURI("{$account_id}/card/new/"); 138 - $payment_method_uri = new PhutilURI($payment_method_uri); 139 - $payment_method_uri->setQueryParams( 140 - array( 141 - 'merchantID' => $merchant->getID(), 142 - 'cartID' => $cart->getID(), 143 - )); 143 + $payment_method_uri = new PhutilURI($payment_method_uri, $params); 144 144 145 145 $form = id(new AphrontFormView()) 146 146 ->setUser($viewer)
+8 -6
src/applications/phortune/provider/PhortunePayPalPaymentProvider.php
··· 348 348 ->setRawPayPalQuery('SetExpressCheckout', $params) 349 349 ->resolve(); 350 350 351 - $uri = new PhutilURI('https://www.sandbox.paypal.com/cgi-bin/webscr'); 352 - $uri->setQueryParams( 353 - array( 354 - 'cmd' => '_express-checkout', 355 - 'token' => $result['TOKEN'], 356 - )); 351 + $params = array( 352 + 'cmd' => '_express-checkout', 353 + 'token' => $result['TOKEN'], 354 + ); 355 + 356 + $uri = new PhutilURI( 357 + 'https://www.sandbox.paypal.com/cgi-bin/webscr', 358 + $params); 357 359 358 360 $cart->setMetadataValue('provider.checkoutURI', (string)$uri); 359 361 $cart->save();
+1 -2
src/applications/phortune/provider/PhortunePaymentProvider.php
··· 273 273 $app = PhabricatorApplication::getByClass('PhabricatorPhortuneApplication'); 274 274 $path = $app->getBaseURI().'provider/'.$id.'/'.$action.'/'; 275 275 276 - $uri = new PhutilURI($path); 277 - $uri->setQueryParams($params); 276 + $uri = new PhutilURI($path, $params); 278 277 279 278 if ($local) { 280 279 return $uri;
+1 -7
src/applications/repository/storage/PhabricatorRepository.php
··· 820 820 return $uri; 821 821 } 822 822 823 - $uri = new PhutilURI($uri); 824 - 825 823 if (isset($params['lint'])) { 826 824 $params['params'] = idx($params, 'params', array()) + array( 827 825 'lint' => $params['lint'], ··· 830 828 831 829 $query = idx($params, 'params', array()) + $query; 832 830 833 - if ($query) { 834 - $uri->setQueryParams($query); 835 - } 836 - 837 - return $uri; 831 + return new PhutilURI($uri, $query); 838 832 } 839 833 840 834 public function updateURIIndex() {
+1 -2
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1541 1541 $config_uri = $config->getCreateURI(); 1542 1542 1543 1543 if ($parameters) { 1544 - $config_uri = (string)id(new PhutilURI($config_uri)) 1545 - ->setQueryParams($parameters); 1544 + $config_uri = (string)new PhutilURI($config_uri, $parameters); 1546 1545 } 1547 1546 1548 1547 $specs[] = array(
+4 -4
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
··· 99 99 } 100 100 101 101 public function getDatasourceURI() { 102 - $uri = new PhutilURI('/typeahead/class/'.get_class($this).'/'); 103 - $uri->setQueryParams($this->newURIParameters()); 102 + $params = $this->newURIParameters(); 103 + $uri = new PhutilURI('/typeahead/class/'.get_class($this).'/', $params); 104 104 return phutil_string_cast($uri); 105 105 } 106 106 ··· 109 109 return null; 110 110 } 111 111 112 - $uri = new PhutilURI('/typeahead/browse/'.get_class($this).'/'); 113 - $uri->setQueryParams($this->newURIParameters()); 112 + $params = $this->newURIParameters(); 113 + $uri = new PhutilURI('/typeahead/browse/'.get_class($this).'/', $params); 114 114 return phutil_string_cast($uri); 115 115 } 116 116