1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Replace all "setQueryParam()" calls with "remove/replaceQueryParam()"

Summary: Ref T13250. See D20149. Mostly: clarify semantics. Partly: remove magic "null" behavior.

Test Plan: Poked around, but mostly just inspection since these are pretty much one-for-one.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: yelirekim

Maniphest Tasks: T13250

Differential Revision: https://secure.phabricator.com/D20154
This commit is contained in:
epriestley 2019-02-12 13:35:59 -08:00
parent 241f06c9ff
commit 5892c78986
40 changed files with 87 additions and 75 deletions

View file

@ -594,7 +594,7 @@ final class AphrontRequest extends Phobject {
$request_uri = idx($_SERVER, 'REQUEST_URI', '/');
$uri = new PhutilURI($request_uri);
$uri->setQueryParam('__path__', null);
$uri->removeQueryParam('__path__');
$path = phutil_escape_uri($this->getPath());
$uri->setPath($path);

View file

@ -137,7 +137,7 @@ abstract class AlmanacController
$phid = $object->getPHID();
$add_uri = id(new PhutilURI($edit_base))
->setQueryParam('objectPHID', $object->getPHID());
->replaceQueryParam('objectPHID', $object->getPHID());
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,

View file

@ -95,7 +95,7 @@ abstract class PhabricatorAuthController extends PhabricatorController {
private function buildLoginValidateResponse(PhabricatorUser $user) {
$validate_uri = new PhutilURI($this->getApplicationURI('validate/'));
$validate_uri->setQueryParam('expect', $user->getUsername());
$validate_uri->replaceQueryParam('expect', $user->getUsername());
return id(new AphrontRedirectResponse())->setURI((string)$validate_uri);
}

View file

@ -54,7 +54,7 @@ final class PhabricatorAuthStartController
}
$redirect_uri = $request->getRequestURI();
$redirect_uri->setQueryParam('cleared', 1);
$redirect_uri->replaceQueryParam('cleared', 1);
return id(new AphrontRedirectResponse())->setURI($redirect_uri);
}
}
@ -64,7 +64,7 @@ final class PhabricatorAuthStartController
// the workflow will continue normally.
if ($did_clear) {
$redirect_uri = $request->getRequestURI();
$redirect_uri->setQueryParam('cleared', null);
$redirect_uri->removeQueryParam('cleared');
return id(new AphrontRedirectResponse())->setURI($redirect_uri);
}

View file

@ -32,7 +32,7 @@ final class PhabricatorAuthNewController
$provider_class = get_class($provider);
$provider_uri = id(new PhutilURI('/config/edit/'))
->setQueryParam('provider', $provider_class);
->replaceQueryParam('provider', $provider_class);
$provider_uri = $this->getApplicationURI($provider_uri);
$already_exists = isset($configured_classes[get_class($provider)]);

View file

@ -45,7 +45,7 @@ final class PhabricatorAuthFactorProviderEditController
foreach ($factors as $factor_key => $factor) {
$factor_uri = id(new PhutilURI('/mfa/edit/'))
->setQueryParam('providerFactorKey', $factor_key);
->replaceQueryParam('providerFactorKey', $factor_key);
$factor_uri = $this->getApplicationURI($factor_uri);
$is_enabled = $factor->canCreateNewProvider();

View file

@ -42,7 +42,7 @@ final class PhabricatorAuthMainMenuBarExtension
$uri = new PhutilURI('/auth/start/');
if ($controller) {
$path = $controller->getRequest()->getPath();
$uri->setQueryParam('next', $path);
$uri->replaceQueryParam('next', $path);
}
return id(new PHUIButtonView())

View file

@ -234,7 +234,7 @@ final class PhabricatorCalendarImportViewController
$all_uri = $this->getApplicationURI('import/log/');
$all_uri = (string)id(new PhutilURI($all_uri))
->setQueryParam('importSourcePHID', $import->getPHID());
->replaceQueryParam('importSourcePHID', $import->getPHID());
$all_button = id(new PHUIButtonView())
->setTag('a')
@ -273,8 +273,8 @@ final class PhabricatorCalendarImportViewController
$all_uri = $this->getApplicationURI();
$all_uri = (string)id(new PhutilURI($all_uri))
->setQueryParam('importSourcePHID', $import->getPHID())
->setQueryParam('display', 'list');
->replaceQueryParam('importSourcePHID', $import->getPHID())
->replaceQueryParam('display', 'list');
$all_button = id(new PHUIButtonView())
->setTag('a')

View file

@ -40,7 +40,7 @@ final class PhabricatorWebServerSetupCheck extends PhabricatorSetupCheck {
$base_uri = id(new PhutilURI($base_uri))
->setPath($send_path)
->setQueryParam($expect_key, $expect_value);
->replaceQueryParam($expect_key, $expect_value);
$self_future = id(new HTTPSFuture($base_uri))
->addHeader('X-Phabricator-SelfCheck', 1)

View file

@ -188,7 +188,7 @@ final class ConpherenceViewController extends
} else {
// user not logged in so give them a login button.
$login_href = id(new PhutilURI('/auth/start/'))
->setQueryParam('next', '/'.$conpherence->getMonogram());
->replaceQueryParam('next', '/'.$conpherence->getMonogram());
return id(new PHUIFormLayoutView())
->addClass('login-to-participate')
->appendInstructions(pht('Log in to join this room and participate.'))

View file

@ -287,7 +287,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
$edit_uri = "/dashboard/panel/edit/{$panel_id}/";
$edit_uri = new PhutilURI($edit_uri);
if ($dashboard_id) {
$edit_uri->setQueryParam('dashboardID', $dashboard_id);
$edit_uri->replaceQueryParam('dashboardID', $dashboard_id);
}
$action_edit = id(new PHUIIconView())
@ -303,7 +303,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
$remove_uri = "/dashboard/removepanel/{$dashboard_id}/";
$remove_uri = id(new PhutilURI($remove_uri))
->setQueryParam('panelPHID', $panel_phid);
->replaceQueryParam('panelPHID', $panel_phid);
$action_remove = id(new PHUIIconView())
->setIcon('fa-trash-o')

View file

@ -113,11 +113,11 @@ final class PhabricatorDashboardRenderingEngine extends Phobject {
$dashboard_id = $this->dashboard->getID();
$create_uri = id(new PhutilURI('/dashboard/panel/create/'))
->setQueryParam('dashboardID', $dashboard_id)
->setQueryParam('column', $column);
->replaceQueryParam('dashboardID', $dashboard_id)
->replaceQueryParam('column', $column);
$add_uri = id(new PhutilURI('/dashboard/addpanel/'.$dashboard_id.'/'))
->setQueryParam('column', $column);
->replaceQueryParam('column', $column);
$create_button = id(new PHUIButtonView())
->setTag('a')

View file

@ -71,7 +71,7 @@ final class DifferentialDiffCreateController extends DifferentialController {
$uri = $this->getApplicationURI("diff/{$diff_id}/");
$uri = new PhutilURI($uri);
if ($revision) {
$uri->setQueryParam('revisionID', $revision->getID());
$uri->replaceQueryParam('revisionID', $revision->getID());
}
return id(new AphrontRedirectResponse())->setURI($uri);

View file

@ -11,7 +11,7 @@ final class PhabricatorFactHomeController extends PhabricatorFactController {
if ($request->isFormPost()) {
$uri = new PhutilURI('/fact/chart/');
$uri->setQueryParam('y1', $request->getStr('y1'));
$uri->replaceQueryParam('y1', $request->getStr('y1'));
return id(new AphrontRedirectResponse())->setURI($uri);
}

View file

@ -70,7 +70,7 @@ final class PhabricatorFileLightboxController
if (!$viewer->isLoggedIn()) {
$login_href = id(new PhutilURI('/auth/start/'))
->setQueryParam('next', '/'.$file->getMonogram());
->replaceQueryParam('next', '/'.$file->getMonogram());
return id(new PHUIFormLayoutView())
->addClass('phui-comment-panel-empty')
->appendChild(

View file

@ -61,7 +61,7 @@ final class PhabricatorFileTransformListController
$view_href = $file->getURIForTransform($xform);
$view_href = new PhutilURI($view_href);
$view_href->setQueryParam('regenerate', 'true');
$view_href->replaceQueryParam('regenerate', 'true');
$view_text = pht('Regenerate');

View file

@ -149,7 +149,7 @@ final class PhabricatorImageRemarkupRule extends PhutilRemarkupRule {
));
} else {
$src_uri = id(new PhutilURI('/file/imageproxy/'))
->setQueryParam('uri', $uri);
->replaceQueryParam('uri', $uri);
$img = id(new PHUIRemarkupImageView())
->setURI($src_uri)

View file

@ -300,9 +300,9 @@ final class ManiphestTaskDetailController extends ManiphestController {
$subtask_form = head($subtask_options);
$form_key = $subtask_form->getIdentifier();
$subtask_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))
->setQueryParam('parent', $id)
->setQueryParam('template', $id)
->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
->replaceQueryParam('parent', $id)
->replaceQueryParam('template', $id)
->replaceQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
$subtask_workflow = false;
}

View file

@ -47,9 +47,9 @@ final class ManiphestTaskSubtaskController
$subtype = $subtype_map->getSubtype($subtype_key);
$subtask_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))
->setQueryParam('parent', $id)
->setQueryParam('template', $id)
->setQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
->replaceQueryParam('parent', $id)
->replaceQueryParam('template', $id)
->replaceQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
$subtask_uri = $this->getApplicationURI($subtask_uri);
$item = id(new PHUIObjectItemView())

View file

@ -135,7 +135,7 @@ final class ManiphestTaskListView extends ManiphestView {
if ($this->showBatchControls) {
$href = new PhutilURI('/maniphest/task/edit/'.$task->getID().'/');
if (!$this->showSubpriorityControls) {
$href->setQueryParam('ungrippable', 'true');
$href->replaceQueryParam('ungrippable', 'true');
}
$item->addAction(
id(new PHUIListItemView())

View file

@ -302,11 +302,11 @@ final class MultimeterSampleController extends MultimeterController {
if (!strlen($group)) {
$group = null;
}
$uri->setQueryParam('group', $group);
$uri->replaceQueryParam('group', $group);
if ($wipe) {
foreach ($this->getColumnMap() as $key => $column) {
$uri->setQueryParam($key, null);
$uri->removeQueryParam($key);
}
}
@ -317,7 +317,7 @@ final class MultimeterSampleController extends MultimeterController {
$value = (array)$value;
$uri = clone $this->getRequest()->getRequestURI();
$uri->setQueryParam($key, implode(',', $value));
$uri->replaceQueryParam($key, implode(',', $value));
return phutil_tag(
'a',

View file

@ -153,7 +153,7 @@ final class PhabricatorNotificationServerRef
$instance = PhabricatorEnv::getEnvConfig('cluster.instance');
if (strlen($instance)) {
$uri->setQueryParam('instance', $instance);
$uri->replaceQueryParam('instance', $instance);
}
return $uri;

View file

@ -25,7 +25,7 @@ final class PhabricatorNotificationPanelController
$notifications_view = $builder->buildView();
$content = $notifications_view->render();
$clear_uri->setQueryParam(
$clear_uri->replaceQueryParam(
'chronoKey',
head($stories)->getChronologicalKey());
} else {

View file

@ -111,7 +111,7 @@ final class PhabricatorNotificationSearchEngine
->setUser($viewer);
$view = $builder->buildView();
$clear_uri->setQueryParam(
$clear_uri->replaceQueryParam(
'chronoKey',
head($notifications)->getChronologicalKey());
} else {

View file

@ -36,7 +36,7 @@ final class PhabricatorOAuthResponse extends AphrontResponse {
$base_uri = $this->getClientURI();
$query_params = $this->buildResponseDict();
foreach ($query_params as $key => $value) {
$base_uri->setQueryParam($key, $value);
$base_uri->replaceQueryParam($key, $value);
}
return $base_uri;
}

View file

@ -306,7 +306,7 @@ final class PhabricatorOAuthServerAuthController
foreach ($params as $key => $value) {
if (strlen($value)) {
$full_uri->setQueryParam($key, $value);
$full_uri->replaceQueryParam($key, $value);
}
}

View file

@ -133,7 +133,7 @@ final class PholioMockImagesView extends AphrontView {
);
$login_uri = id(new PhutilURI('/login/'))
->setQueryParam('next', (string)$this->getRequestURI());
->replaceQueryParam('next', (string)$this->getRequestURI());
$config = array(
'mockID' => $mock->getID(),

View file

@ -143,7 +143,7 @@ final class PhortunePaymentMethodCreateController
"cart/{$cart_id}/checkout/?paymentMethodID=".$method->getID());
} else if ($subscription_id) {
$next_uri = new PhutilURI($cancel_uri);
$next_uri->setQueryParam('added', true);
$next_uri->replaceQueryParam('added', true);
} else {
$account_uri = $this->getApplicationURI($account->getID().'/');
$next_uri = new PhutilURI($account_uri);

View file

@ -118,8 +118,8 @@ final class PhortuneSubscriptionEditController extends PhortuneController {
$uri = $this->getApplicationURI($account->getID().'/card/new/');
$uri = new PhutilURI($uri);
$uri->setQueryParam('merchantID', $merchant->getID());
$uri->setQueryParam('subscriptionID', $subscription->getID());
$uri->replaceQueryParam('merchantID', $merchant->getID());
$uri->replaceQueryParam('subscriptionID', $subscription->getID());
$add_method_button = phutil_tag(
'a',

View file

@ -66,7 +66,7 @@ final class PonderAddAnswerView extends AphrontView {
if (!$viewer->isLoggedIn()) {
$login_href = id(new PhutilURI('/auth/start/'))
->setQueryParam('next', '/Q'.$question->getID());
->replaceQueryParam('next', '/Q'.$question->getID());
$form = id(new PHUIFormLayoutView())
->addClass('login-to-participate')
->appendChild(

View file

@ -284,7 +284,7 @@ final class PhabricatorProjectBoardViewController
$query_key = $saved_query->getQueryKey();
$bulk_uri = new PhutilURI("/maniphest/bulk/query/{$query_key}/");
$bulk_uri->setQueryParam('board', $this->id);
$bulk_uri->replaceQueryParam('board', $this->id);
return id(new AphrontRedirectResponse())
->setURI($bulk_uri);
@ -878,7 +878,7 @@ final class PhabricatorProjectBoardViewController
}
$uri = $this->getURIWithState($uri)
->setQueryParam('filter', null);
->removeQueryParam('filter');
$item->setHref($uri);
$items[] = $item;
@ -966,12 +966,12 @@ final class PhabricatorProjectBoardViewController
if ($show_hidden) {
$hidden_uri = $this->getURIWithState()
->setQueryParam('hidden', null);
->removeQueryParam('hidden');
$hidden_icon = 'fa-eye-slash';
$hidden_text = pht('Hide Hidden Columns');
} else {
$hidden_uri = $this->getURIWithState()
->setQueryParam('hidden', 'true');
->replaceQueryParam('hidden', 'true');
$hidden_icon = 'fa-eye';
$hidden_text = pht('Show Hidden Columns');
}
@ -999,7 +999,7 @@ final class PhabricatorProjectBoardViewController
->setHref($manage_uri);
$batch_edit_uri = $request->getRequestURI();
$batch_edit_uri->setQueryParam('batch', self::BATCH_EDIT_ALL);
$batch_edit_uri->replaceQueryParam('batch', self::BATCH_EDIT_ALL);
$can_batch_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
PhabricatorApplication::getByClass('PhabricatorManiphestApplication'),
@ -1090,7 +1090,7 @@ final class PhabricatorProjectBoardViewController
}
$batch_edit_uri = $request->getRequestURI();
$batch_edit_uri->setQueryParam('batch', $column->getID());
$batch_edit_uri->replaceQueryParam('batch', $column->getID());
$can_batch_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
PhabricatorApplication::getByClass('PhabricatorManiphestApplication'),
@ -1103,7 +1103,7 @@ final class PhabricatorProjectBoardViewController
->setDisabled(!$can_batch_edit);
$batch_move_uri = $request->getRequestURI();
$batch_move_uri->setQueryParam('move', $column->getID());
$batch_move_uri->replaceQueryParam('move', $column->getID());
$column_items[] = id(new PhabricatorActionView())
->setIcon('fa-arrow-right')
->setName(pht('Move Tasks to Column...'))
@ -1111,7 +1111,7 @@ final class PhabricatorProjectBoardViewController
->setWorkflow(true);
$query_uri = $request->getRequestURI();
$query_uri->setQueryParam('queryColumnID', $column->getID());
$query_uri->replaceQueryParam('queryColumnID', $column->getID());
$column_items[] = id(new PhabricatorActionView())
->setName(pht('View as Query'))
@ -1188,18 +1188,22 @@ final class PhabricatorProjectBoardViewController
$base = new PhutilURI($base);
if ($force || ($this->sortKey != $this->getDefaultSort($project))) {
$base->setQueryParam('order', $this->sortKey);
$base->replaceQueryParam('order', $this->sortKey);
} else {
$base->setQueryParam('order', null);
$base->removeQueryParam('order');
}
if ($force || ($this->queryKey != $this->getDefaultFilter($project))) {
$base->setQueryParam('filter', $this->queryKey);
$base->replaceQueryParam('filter', $this->queryKey);
} else {
$base->setQueryParam('filter', null);
$base->removeQueryParam('filter');
}
$base->setQueryParam('hidden', $this->showHidden ? 'true' : null);
if ($this->showHidden) {
$base->replaceQueryParam('hidden', 'true');
} else {
$base->removeQueryParam('hidden');
}
return $base;
}

View file

@ -41,7 +41,7 @@ final class PhabricatorProjectColumnHideController
$view_uri = $this->getApplicationURI('/board/'.$project_id.'/');
$view_uri = new PhutilURI($view_uri);
foreach ($request->getPassthroughRequestData() as $key => $value) {
$view_uri->setQueryParam($key, $value);
$view_uri->replaceQueryParam($key, $value);
}
if ($column->isDefaultColumn()) {

View file

@ -54,7 +54,7 @@ final class PhabricatorProjectDefaultController
$view_uri = $this->getApplicationURI("board/{$id}/");
$view_uri = new PhutilURI($view_uri);
foreach ($request->getPassthroughRequestData() as $key => $value) {
$view_uri->setQueryParam($key, $value);
$view_uri->replaceQueryParam($key, $value);
}
if ($request->isFormPost()) {

View file

@ -96,7 +96,7 @@ final class ReleephRequestDifferentialCreateController
private function buildReleephRequestURI(ReleephBranch $branch) {
$uri = $branch->getURI('request/');
return id(new PhutilURI($uri))
->setQueryParam('D', $this->revision->getID());
->replaceQueryParam('D', $this->revision->getID());
}
}

View file

@ -905,7 +905,7 @@ final class PhabricatorApplicationSearchController
$engine = $this->getSearchEngine();
$nux_uri = $engine->getQueryBaseURI();
$nux_uri = id(new PhutilURI($nux_uri))
->setQueryParam('nux', true);
->replaceQueryParam('nux', true);
$actions[] = id(new PhabricatorActionView())
->setIcon('fa-user-plus')
@ -915,7 +915,7 @@ final class PhabricatorApplicationSearchController
if ($is_dev) {
$overheated_uri = $this->getRequest()->getRequestURI()
->setQueryParam('overheated', true);
->replaceQueryParam('overheated', true);
$actions[] = id(new PhabricatorActionView())
->setIcon('fa-fire')

View file

@ -219,7 +219,7 @@ final class PhabricatorMultiFactorSettingsPanel
foreach ($providers as $provider_phid => $provider) {
$provider_uri = id(new PhutilURI($this->getPanelURI()))
->setQueryParam('providerPHID', $provider_phid);
->replaceQueryParam('providerPHID', $provider_phid);
$is_enabled = $provider->canCreateNewConfiguration($viewer);

View file

@ -198,7 +198,7 @@ final class PhabricatorApplicationTransactionCommentView
$viewer = $this->getViewer();
if (!$viewer->isLoggedIn()) {
$uri = id(new PhutilURI('/login/'))
->setQueryParam('next', (string)$this->getRequestURI());
->replaceQueryParam('next', (string)$this->getRequestURI());
return id(new PHUIObjectBoxView())
->setFlush(true)
->appendChild(

View file

@ -126,10 +126,10 @@ final class PhabricatorTypeaheadModularDatasourceController
$results = array_slice($results, 0, $limit, $preserve_keys = true);
if (($offset + (2 * $limit)) < $hard_limit) {
$next_uri = id(new PhutilURI($request->getRequestURI()))
->setQueryParam('offset', $offset + $limit)
->setQueryParam('q', $query)
->setQueryParam('raw', $raw_query)
->setQueryParam('format', 'html');
->replaceQueryParam('offset', $offset + $limit)
->replaceQueryParam('q', $query)
->replaceQueryParam('raw', $raw_query)
->replaceQueryParam('format', 'html');
$next_link = javelin_tag(
'a',
@ -248,7 +248,9 @@ final class PhabricatorTypeaheadModularDatasourceController
$parameters = $source->getParameters();
if ($parameters) {
$reference_uri = (string)id(new PhutilURI($reference_uri))
->setQueryParam('parameters', phutil_json_encode($parameters));
->replaceQueryParam(
'parameters',
phutil_json_encode($parameters));
}
$reference_link = phutil_tag(

View file

@ -475,11 +475,17 @@ final class PhabricatorEnv extends Phobject {
* @task read
*/
public static function getDoclink($resource, $type = 'article') {
$uri = new PhutilURI('https://secure.phabricator.com/diviner/find/');
$uri->setQueryParam('name', $resource);
$uri->setQueryParam('type', $type);
$uri->setQueryParam('jump', true);
return (string)$uri;
$params = array(
'name' => $resource,
'type' => $type,
'jump' => true,
);
$uri = new PhutilURI(
'https://secure.phabricator.com/diviner/find/',
$params);
return phutil_string_cast($uri);
}

View file

@ -154,8 +154,8 @@ final class PHUITimelineView extends AphrontView {
}
$uri = $this->getPager()->getNextPageURI();
$uri->setQueryParam('quoteTargetID', $this->getQuoteTargetID());
$uri->setQueryParam('quoteRef', $this->getQuoteRef());
$uri->replaceQueryParam('quoteTargetID', $this->getQuoteTargetID());
$uri->replaceQueryParam('quoteRef', $this->getQuoteRef());
$events[] = javelin_tag(
'div',
array(