Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
300
Merge Requests
300
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
18ddb004
Commit
18ddb004
authored
Aug 07, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2315807
by tim.plunkett: Remove support for path-based form redirects.
parent
0f3327fe
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
118 additions
and
216 deletions
+118
-216
core/includes/batch.inc
core/includes/batch.inc
+10
-6
core/includes/form.inc
core/includes/form.inc
+1
-1
core/lib/Drupal/Core/Annotation/Action.php
core/lib/Drupal/Core/Annotation/Action.php
+2
-3
core/lib/Drupal/Core/Form/FormState.php
core/lib/Drupal/Core/Form/FormState.php
+9
-25
core/lib/Drupal/Core/Form/FormStateInterface.php
core/lib/Drupal/Core/Form/FormStateInterface.php
+0
-4
core/lib/Drupal/Core/Form/FormSubmitter.php
core/lib/Drupal/Core/Form/FormSubmitter.php
+5
-34
core/lib/Drupal/Core/Form/FormSubmitterInterface.php
core/lib/Drupal/Core/Form/FormSubmitterInterface.php
+8
-31
core/modules/content_translation/src/ContentTranslationHandler.php
...les/content_translation/src/ContentTranslationHandler.php
+11
-5
core/modules/field_ui/src/FieldOverview.php
core/modules/field_ui/src/FieldOverview.php
+1
-7
core/modules/field_ui/src/FieldUI.php
core/modules/field_ui/src/FieldUI.php
+4
-2
core/modules/field_ui/src/Form/FieldInstanceEditForm.php
core/modules/field_ui/src/Form/FieldInstanceEditForm.php
+1
-6
core/modules/field_ui/src/Form/FieldStorageEditForm.php
core/modules/field_ui/src/Form/FieldStorageEditForm.php
+1
-6
core/modules/file/file.module
core/modules/file/file.module
+1
-1
core/modules/node/src/Plugin/Action/DeleteNode.php
core/modules/node/src/Plugin/Action/DeleteNode.php
+1
-1
core/modules/path/src/Form/DeleteForm.php
core/modules/path/src/Form/DeleteForm.php
+1
-1
core/modules/system/src/Plugin/views/field/BulkForm.php
core/modules/system/src/Plugin/views/field/BulkForm.php
+2
-2
core/modules/system/system.module
core/modules/system/system.module
+13
-7
core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
...m/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
+1
-1
core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
...modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
+1
-1
core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
...tests/modules/form_test/src/Form/FormTestRedirectForm.php
+5
-2
core/modules/taxonomy/src/Form/OverviewTerms.php
core/modules/taxonomy/src/Form/OverviewTerms.php
+0
-1
core/modules/taxonomy/src/TermForm.php
core/modules/taxonomy/src/TermForm.php
+0
-4
core/modules/update/src/Form/UpdateManagerInstall.php
core/modules/update/src/Form/UpdateManagerInstall.php
+1
-1
core/modules/update/src/Form/UpdateReady.php
core/modules/update/src/Form/UpdateReady.php
+1
-1
core/modules/user/src/Plugin/Action/CancelUser.php
core/modules/user/src/Plugin/Action/CancelUser.php
+1
-1
core/modules/user/src/RegisterForm.php
core/modules/user/src/RegisterForm.php
+0
-6
core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
...s/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
+0
-1
core/modules/views_ui/src/ViewEditForm.php
core/modules/views_ui/src/ViewEditForm.php
+24
-13
core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
+1
-1
core/tests/Drupal/Tests/Core/Form/FormStateTest.php
core/tests/Drupal/Tests/Core/Form/FormStateTest.php
+1
-7
core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
+11
-34
No files found.
core/includes/batch.inc
View file @
18ddb004
...
...
@@ -16,9 +16,11 @@
use
Drupal\Component\Utility\SafeMarkup
;
use
Drupal\Component\Utility\Timer
;
use
Drupal\Component\Utility\UrlHelper
;
use
Drupal\Core\Batch\Percentage
;
use
Drupal\Core\Form\FormState
;
use
Drupal\Core\Page\DefaultHtmlPageRenderer
;
use
Drupal\Core\Url
;
use
Symfony\Component\HttpFoundation\JsonResponse
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
...
...
@@ -446,13 +448,15 @@ function _batch_finished() {
if
(
!
isset
(
$_batch
[
'form_state'
]))
{
$_batch
[
'form_state'
]
=
new
FormState
();
}
if
(
!
isset
(
$_batch
[
'form_state'
][
'redirect'
]))
{
if
(
isset
(
$_batch
[
'redirect'
]))
{
$_batch
[
'form_state'
][
'redirect'
]
=
$_batch
[
'redirect'
];
}
else
{
$_batch
[
'form_state'
][
'redirect'
]
=
$_batch
[
'source_url'
];
if
(
$_batch
[
'form_state'
]
->
getRedirect
()
===
NULL
)
{
$redirect
=
$_batch
[
'batch_redirect'
]
?:
$_batch
[
'source_url'
];
$options
=
UrlHelper
::
parse
(
$redirect
);
if
(
!
UrlHelper
::
isExternal
(
$options
[
'path'
]))
{
$options
[
'path'
]
=
$GLOBALS
[
'base_url'
]
.
'/'
.
$options
[
'path'
];
}
$redirect
=
Url
::
createFromPath
(
$options
[
'path'
]);
$redirect
->
setOptions
(
$options
);
$_batch
[
'form_state'
]
->
setRedirectUrl
(
$redirect
);
}
// Use \Drupal\Core\Form\FormSubmitterInterface::redirectForm() to handle
...
...
core/includes/form.inc
View file @
18ddb004
...
...
@@ -3066,7 +3066,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU
'url'
=>
$url
,
'url_options'
=>
array
(),
'source_url'
=>
current_path
(),
'redirect'
=>
$redirect
,
'
batch_
redirect'
=>
$redirect
,
'theme'
=>
$GLOBALS
[
'theme_key'
],
'redirect_callback'
=>
$redirect_callback
,
);
...
...
core/lib/Drupal/Core/Annotation/Action.php
View file @
18ddb004
...
...
@@ -42,14 +42,13 @@ class Action extends Plugin {
public
$label
;
/**
* The
path
for a confirmation form for this action.
* The
route name
for a confirmation form for this action.
*
* @todo Change this to accept a route.
* @todo Provide a more generic way to allow an action to be confirmed first.
*
* @var string (optional)
*/
public
$confirm_form_
path
=
''
;
public
$confirm_form_
route_name
=
''
;
/**
* The entity type the action can apply to.
...
...
core/lib/Drupal/Core/Form/FormState.php
View file @
18ddb004
...
...
@@ -111,33 +111,25 @@ class FormState implements FormStateInterface, \ArrayAccess {
* Used when a form needs to return some kind of a
* \Symfony\Component\HttpFoundation\Response object, e.g., a
* \Symfony\Component\HttpFoundation\BinaryFileResponse when triggering a
* file download. If you use the $form_state['redirect'] key, it will be used
* to build a \Symfony\Component\HttpFoundation\RedirectResponse and will
* populate this key.
* file download. If you use self::setRedirect() or self::setRedirectUrl(),
* it will be used to build a
* \Symfony\Component\HttpFoundation\RedirectResponse and will populate this
* key.
*
* @var \Symfony\Component\HttpFoundation\Response|null
*/
protected
$response
;
/**
* Used to redirect the form on submission. It may either be a string
* containing the destination URL, or an array of arguments compatible with
* url(). See url() for complete information.
* Used to redirect the form on submission.
*
* This property is uncacheable.
*
* @var string|array|null
*/
protected
$redirect
;
/**
* Used for route-based redirects.
* @see self::getRedirect()
*
* This property is uncacheable.
*
* @var \Drupal\Core\Url|
array
* @var \Drupal\Core\Url|
\Symfony\Component\HttpFoundation\RedirectResponse|null
*/
protected
$redirect
_route
;
protected
$redirect
;
/**
* If set to TRUE the form will NOT perform a redirect, even if
...
...
@@ -611,7 +603,7 @@ public function setRedirect($route_name, array $route_parameters = array(), arra
* {@inheritdoc}
*/
public
function
setRedirectUrl
(
Url
$url
)
{
$this
->
set
(
'redirect
_route
'
,
$url
);
$this
->
set
(
'redirect'
,
$url
);
return
$this
;
}
...
...
@@ -633,14 +625,6 @@ public function getRedirect() {
return
FALSE
;
}
// Check for a route-based redirection.
if
(
$redirect_route
=
$this
->
get
(
'redirect_route'
))
{
$redirect_route
->
setAbsolute
();
return
$redirect_route
;
}
// @todo Remove once all redirects are converted away from paths in
// https://www.drupal.org/node/2315807.
return
$this
->
get
(
'redirect'
);
}
...
...
core/lib/Drupal/Core/Form/FormStateInterface.php
View file @
18ddb004
...
...
@@ -127,10 +127,6 @@ public function setRedirectUrl(Url $url);
* The value will be one of the following:
* - A fully prepared \Symfony\Component\HttpFoundation\RedirectResponse.
* - An instance of \Drupal\Core\Url to use for the redirect.
* - A numerically-indexed array where the first value is the path to use
* for the redirect, and the optional second value is an array of options
* for generating the URL from the path.
* - The path to use for the redirect.
* - NULL, to signify that no redirect was specified and that the current
* path should be used for the redirect.
* - FALSE, to signify that no redirect should take place.
...
...
core/lib/Drupal/Core/Form/FormSubmitter.php
View file @
18ddb004
...
...
@@ -127,10 +127,6 @@ public function executeSubmitHandlers(&$form, FormStateInterface &$form_state) {
* {@inheritdoc}
*/
public
function
redirectForm
(
FormStateInterface
$form_state
)
{
// According to RFC 7231, 303 See Other status code must be used to redirect
// user agent (and not default 302 Found).
// @see http://tools.ietf.org/html/rfc7231#section-6.4.4
$status_code
=
Response
::
HTTP_SEE_OTHER
;
$redirect
=
$form_state
->
getRedirect
();
// Allow using redirect responses directly if needed.
...
...
@@ -141,35 +137,7 @@ public function redirectForm(FormStateInterface $form_state) {
$url
=
NULL
;
// Check for a route-based redirection.
if
(
$redirect
instanceof
Url
)
{
$url
=
$redirect
->
toString
();
}
// An array contains the path to use for the redirect, as well as options to
// use for generating the URL.
elseif
(
is_array
(
$redirect
))
{
if
(
isset
(
$redirect
[
1
]))
{
$options
=
$redirect
[
1
];
}
else
{
$options
=
array
();
}
// Redirections should always use absolute URLs.
$options
[
'absolute'
]
=
TRUE
;
if
(
isset
(
$redirect
[
2
]))
{
$status_code
=
$redirect
[
2
];
}
$url
=
$this
->
urlGenerator
->
generateFromPath
(
$redirect
[
0
],
$options
);
}
// A string represents the path to use for the redirect.
elseif
(
is_string
(
$redirect
))
{
// This function can be called from the installer, which guarantees
// that $redirect will always be a string, so catch that case here
// and use the appropriate redirect function.
if
(
$this
->
drupalInstallationAttempted
())
{
install_goto
(
$redirect
);
}
else
{
$url
=
$this
->
urlGenerator
->
generateFromPath
(
$redirect
,
array
(
'absolute'
=>
TRUE
));
}
$url
=
$redirect
->
setAbsolute
()
->
toString
();
}
// If no redirect was specified, redirect to the current path.
elseif
(
$redirect
===
NULL
)
{
...
...
@@ -183,7 +151,10 @@ public function redirectForm(FormStateInterface $form_state) {
}
if
(
$url
)
{
return
new
RedirectResponse
(
$url
,
$status_code
);
// According to RFC 7231, 303 See Other status code must be used to redirect
// user agent (and not default 302 Found).
// @see http://tools.ietf.org/html/rfc7231#section-6.4.4
return
new
RedirectResponse
(
$url
,
Response
::
HTTP_SEE_OTHER
);
}
}
...
...
core/lib/Drupal/Core/Form/FormSubmitterInterface.php
View file @
18ddb004
...
...
@@ -49,21 +49,18 @@ public function executeSubmitHandlers(&$form, FormStateInterface &$form_state);
* destination should be, based on the $form_state and the 'destination'
* query string in the request URL, and redirects the user there.
*
* Usually (for exceptions, see below) $form_state['redirect'] determines
* where to redirect the user. This can be set either to a string (the path to
* redirect to), or an array of arguments for url(). If
* $form_state['redirect'] is missing, the user is usually (again, see below
* for exceptions) redirected back to the page they came from, where they
* should see a fresh, unpopulated copy of the form.
* The result of \Drupal\Core\Form|FormStateInterface::getRedirect()
* determines where to redirect the user. See the possible return values
* listed there. If the result is FALSE, then the user will not be redirected.
*
* Here is an example of how to set up a form to redirect to the path '
node
':
* Here is an example of how to set up a form to redirect to the path '
user
':
* @code
* $form_state->set
('redirect', 'nod
e');
* $form_state->set
Redirect('user.pag
e');
* @endcode
* And here is an example of how to redirect to 'node/123?foo=bar#baz':
* @code
* $form_state->set
('redirect', array(
*
'node/123'
,
* $form_state->set
Redirect('node.view',
*
array('node' => 123)
,
* array(
* 'query' => array(
* 'foo' => 'bar',
...
...
@@ -73,27 +70,7 @@ public function executeSubmitHandlers(&$form, FormStateInterface &$form_state);
* ));
* @endcode
*
* There are several exceptions to the "usual" behavior described above:
* - If $form_state['programmed'] is TRUE, the form submission was usually
* invoked via self::submitForm(), so any redirection would break the script
* that invoked self::submitForm() and no redirection is done.
* - If $form_state['rebuild'] is TRUE, the form is being rebuilt, and no
* redirection is done.
* - If $form_state['no_redirect'] is TRUE, redirection is disabled. This is
* set, for instance, by \Drupal\system\FormAjaxController::getForm() to
* prevent redirection in Ajax callbacks. $form_state['no_redirect'] should
* never be set or altered by form builder functions or form validation
* or submit handlers.
* - If $form_state['redirect'] is set to FALSE, redirection is disabled.
* - If none of the above conditions has prevented redirection, then the
* redirect is accomplished by returning a RedirectResponse, passing in the
* value of $form_state['redirect'] if it is set, or the current path if it
* is not. RedirectResponse preferentially uses the value of
* \Drupal::request->query->get('destination') (the 'destination' URL query
* string) if it is present, so this will override any values set by
* $form_state['redirect'].
*
* @param $form_state
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
...
...
core/modules/content_translation/src/ContentTranslationHandler.php
View file @
18ddb004
...
...
@@ -435,8 +435,12 @@ public function entityFormSourceChange($form, FormStateInterface $form_state) {
$entity
=
$form_controller
->
getEntity
();
$source
=
$form_state
[
'values'
][
'source_langcode'
][
'source'
];
$path
=
$entity
->
getSystemPath
(
'drupal:content-translation-overview'
);
$form_state
[
'redirect'
]
=
$path
.
'/add/'
.
$source
.
'/'
.
$form_controller
->
getFormLangcode
(
$form_state
);
$entity_type_id
=
$entity
->
getEntityTypeId
();
$form_state
->
setRedirect
(
'content_translation.translation_add_'
.
$entity_type_id
,
array
(
$entity_type_id
=>
$entity
->
id
(),
'source'
=>
$source
,
'target'
=>
$form_controller
->
getFormLangcode
(
$form_state
),
));
$languages
=
language_list
();
drupal_set_message
(
t
(
'Source language set to: %language'
,
array
(
'%language'
=>
$languages
[
$source
]
->
name
)));
}
...
...
@@ -462,9 +466,11 @@ function entityFormDelete($form, FormStateInterface $form_state) {
function
entityFormDeleteTranslation
(
$form
,
FormStateInterface
$form_state
)
{
$form_controller
=
content_translation_form_controller
(
$form_state
);
$entity
=
$form_controller
->
getEntity
();
$path
=
$entity
->
getSystemPath
(
'drupal:content-translation-overview'
);
$form_langcode
=
$form_controller
->
getFormLangcode
(
$form_state
);
$form_state
[
'redirect'
]
=
$path
.
'/delete/'
.
$form_langcode
;
$entity_type_id
=
$entity
->
getEntityTypeId
();
$form_state
->
setRedirect
(
'content_translation.delete_'
.
$entity_type_id
,
array
(
$entity_type_id
=>
$entity
->
id
(),
'language'
=>
$form_controller
->
getFormLangcode
(
$form_state
),
));
}
/**
...
...
core/modules/field_ui/src/FieldOverview.php
View file @
18ddb004
...
...
@@ -478,13 +478,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
if
(
$destinations
)
{
$destination
=
drupal_get_destination
();
$destinations
[]
=
$destination
[
'destination'
];
$next_destination
=
FieldUI
::
getNextDestination
(
$destinations
,
$form_state
);
if
(
isset
(
$next_destination
[
'route_name'
]))
{
$form_state
->
setRedirect
(
$next_destination
[
'route_name'
],
$next_destination
[
'route_parameters'
],
$next_destination
[
'options'
]);
}
else
{
$form_state
[
'redirect'
]
=
$next_destination
;
}
$form_state
->
setRedirectUrl
(
FieldUI
::
getNextDestination
(
$destinations
,
$form_state
));
}
elseif
(
!
$error
)
{
drupal_set_message
(
$this
->
t
(
'Your settings have been saved.'
));
...
...
core/modules/field_ui/src/FieldUI.php
View file @
18ddb004
...
...
@@ -41,7 +41,7 @@ public static function getOverviewRouteInfo($entity_type_id, $bundle) {
* @param array $destinations
* An array of destinations to redirect to.
*
* @return
array
* @return
\Drupal\Core\Url
* The next destination to redirect to.
*/
public
static
function
getNextDestination
(
array
$destinations
)
{
...
...
@@ -51,13 +51,15 @@ public static function getNextDestination(array $destinations) {
$next_destination
+=
array
(
'route_parameters'
=>
array
(),
);
$next_destination
=
new
Url
(
$next_destination
[
'route_name'
],
$next_destination
[
'route_parameters'
],
$next_destination
[
'options'
]);
}
else
{
$options
=
UrlHelper
::
parse
(
$next_destination
);
if
(
$destinations
)
{
$options
[
'query'
][
'destinations'
]
=
$destinations
;
}
$next_destination
=
array
(
$options
[
'path'
],
$options
);
$next_destination
=
Url
::
createFromPath
(
$options
[
'path'
]);
$next_destination
->
setOptions
(
$options
);
}
return
$next_destination
;
}
...
...
core/modules/field_ui/src/Form/FieldInstanceEditForm.php
View file @
18ddb004
...
...
@@ -195,12 +195,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$request
=
$this
->
getRequest
();
if
((
$destinations
=
$request
->
query
->
get
(
'destinations'
))
&&
$next_destination
=
FieldUI
::
getNextDestination
(
$destinations
))
{
$request
->
query
->
remove
(
'destinations'
);
if
(
isset
(
$next_destination
[
'route_name'
]))
{
$form_state
->
setRedirect
(
$next_destination
[
'route_name'
],
$next_destination
[
'route_parameters'
],
$next_destination
[
'options'
]);
}
else
{
$form_state
[
'redirect'
]
=
$next_destination
;
}
$form_state
->
setRedirectUrl
(
$next_destination
);
}
else
{
$form_state
->
setRedirectUrl
(
FieldUI
::
getOverviewRouteInfo
(
$this
->
instance
->
entity_type
,
$this
->
instance
->
bundle
));
...
...
core/modules/field_ui/src/Form/FieldStorageEditForm.php
View file @
18ddb004
...
...
@@ -198,12 +198,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$request
=
$this
->
getRequest
();
if
((
$destinations
=
$request
->
query
->
get
(
'destinations'
))
&&
$next_destination
=
FieldUI
::
getNextDestination
(
$destinations
))
{
$request
->
query
->
remove
(
'destinations'
);
if
(
isset
(
$next_destination
[
'route_name'
]))
{
$form_state
->
setRedirect
(
$next_destination
[
'route_name'
],
$next_destination
[
'route_parameters'
],
$next_destination
[
'options'
]);
}
else
{
$form_state
[
'redirect'
]
=
$next_destination
;
}
$form_state
->
setRedirectUrl
(
$next_destination
);
}
else
{
$form_state
->
setRedirectUrl
(
FieldUI
::
getOverviewRouteInfo
(
$this
->
instance
->
entity_type
,
$this
->
instance
->
bundle
));
...
...
core/modules/file/file.module
View file @
18ddb004
...
...
@@ -1418,7 +1418,7 @@ function file_managed_file_submit($form, FormStateInterface $form_state) {
// Set the form to rebuild so that $form is correctly updated in response to
// processing the file removal. Since this function did not change $form_state
// if the upload button was clicked, a rebuild isn't necessary in that
// situation and setting $form_state['
redirect'] to FALS
E would suffice.
// situation and setting $form_state['
no_redirect'] to TRU
E would suffice.
// However, we choose to always rebuild, to keep the form processing workflow
// consistent between the two buttons.
$form_state
[
'rebuild'
]
=
TRUE
;
...
...
core/modules/node/src/Plugin/Action/DeleteNode.php
View file @
18ddb004
...
...
@@ -19,7 +19,7 @@
* id = "node_delete_action",
* label = @Translation("Delete selected content"),
* type = "node",
* confirm_form_
path = "admin/content/node/delete
"
* confirm_form_
route_name = "node.multiple_delete_confirm
"
* )
*/
class
DeleteNode
extends
ActionBase
implements
ContainerFactoryPluginInterface
{
...
...
core/modules/path/src/Form/DeleteForm.php
View file @
18ddb004
...
...
@@ -89,7 +89,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$this
->
aliasStorage
->
delete
(
array
(
'pid'
=>
$this
->
pathAlias
[
'pid'
]));
$form_state
[
'redirect'
]
=
'admin/config/search/path'
;
$form_state
->
setRedirect
(
'path.admin_overview'
)
;
}
}
core/modules/system/src/Plugin/views/field/BulkForm.php
View file @
18ddb004
...
...
@@ -263,8 +263,8 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) {
$action
->
execute
(
$entities
);
$operation_definition
=
$action
->
getPluginDefinition
();
if
(
!
empty
(
$operation_definition
[
'confirm_form_
path
'
]))
{
$form_state
[
'redirect'
]
=
$operation_definition
[
'confirm_form_path'
]
;
if
(
!
empty
(
$operation_definition
[
'confirm_form_
route_name
'
]))
{
$form_state
->
setRedirect
(
$operation_definition
[
'confirm_form_route_name'
])
;
}
$count
=
count
(
array_filter
(
$form_state
[
'values'
][
$this
->
options
[
'id'
]]));
...
...
core/modules/system/system.module
View file @
18ddb004
...
...
@@ -14,6 +14,7 @@
use
Drupal\Core\Language\LanguageInterface
;
use
Drupal\Core\Menu\MenuTreeParameters
;
use
Drupal\block\BlockPluginInterface
;
use
Drupal\Core\Url
;
use
Drupal\user\UserInterface
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
GuzzleHttp\Exception\RequestException
;
...
...
@@ -790,7 +791,7 @@ function _system_themes_access($theme) {
* using the URL from system_authorized_get_url(). Redirecting yourself is
* necessary when your authorized operation is being triggered by a form
* submit handler, since calling redirecting in a submit handler is a bad
* idea, and you should instead
set $form_state['redirect']
.
* idea, and you should instead
use $form_state->setRedirect()
.
*
* Once the SESSION is setup for the operation and the user is redirected to
* authorize.php, they will be prompted for their connection credentials (core
...
...
@@ -817,14 +818,14 @@ function _system_themes_access($theme) {
* not to assume any code exists. Example (system_authorized_run()):
* @code
* system_authorized_init($callback, $file, $arguments, $page_title);
* return new RedirectResponse(system_authorized_get_url());
* return new RedirectResponse(system_authorized_get_url()
->toString()
);
* @endcode
* Example (update_manager_install_form_submit()):
* @code
* system_authorized_init('update_authorize_run_install',
* drupal_get_path('module', 'update') . '/update.authorize.inc',
* $arguments, t('Update manager'));
* $form_state
['redirect'] = system_authorized_get_url(
);
* $form_state
->setRedirectUrl(system_authorized_get_url()
);
* @endcode
*
* @param $callback
...
...
@@ -863,7 +864,7 @@ function system_authorized_init($callback, $file, $arguments = array(), $page_ti
*
* @param array $options
* Optional array of options to pass to url().
* @return
* @return
\Drupal\Core\Url
* The full URL to authorize.php, using HTTPS if available.
*
* @see system_authorized_init()
...
...
@@ -873,7 +874,10 @@ function system_authorized_get_url(array $options = array()) {
// Force HTTPS if available, regardless of what the caller specifies.
$options
[
'https'
]
=
TRUE
;
// Prefix with $base_url so url() treats it as an external link.
return
url
(
$base_url
.
'/core/authorize.php'
,
$options
);
$url
=
Url
::
createFromPath
(
$base_url
.
'/core/authorize.php'
);
$url_options
=
$url
->
getOptions
();
$url
->
setOptions
(
$options
+
$url_options
);
return
$url
;
}
/**
...
...
@@ -881,6 +885,8 @@ function system_authorized_get_url(array $options = array()) {
*
* @param array $options
* Optional array of options to pass to url().
*
* @return \Drupal\Core\Url
*/
function
system_authorized_batch_processing_url
(
array
$options
=
array
())
{
$options
[
'query'
]
=
array
(
'batch'
=>
'1'
);
...
...
@@ -894,7 +900,7 @@ function system_authorized_batch_processing_url(array $options = array()) {
*/
function
system_authorized_run
(
$callback
,
$file
,
$arguments
=
array
(),
$page_title
=
NULL
)
{
system_authorized_init
(
$callback
,
$file
,
$arguments
,
$page_title
);
return
new
RedirectResponse
(
system_authorized_get_url
());
return
new
RedirectResponse
(
system_authorized_get_url
()
->
toString
()
);
}
/**
...
...
@@ -905,7 +911,7 @@ function system_authorized_run($callback, $file, $arguments = array(), $page_tit
function
system_authorized_batch_process
()
{
$finish_url
=
system_authorized_get_url
();
$process_url
=
system_authorized_batch_processing_url
();
return
batch_process
(
$finish_url
,
$process_url
);
return
batch_process
(
$finish_url
->
toString
(),
$process_url
->
toString
()
);
}
/**
...
...
core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php
View file @
18ddb004
...
...
@@ -68,7 +68,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$form_state
[
'redirect'
]
=
'ajax-test/dialog-contents'
;
$form_state
->
setRedirect
(
'ajax_test.dialog_contents'
)
;
}
...
...
core/modules/system/tests/modules/form_test/src/Form/FormTestCheckboxesZeroForm.php
View file @
18ddb004
...
...
@@ -60,7 +60,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->
setResponse
(
new
JsonResponse
(
$form_state
[
'values'
]));
}
else
{
$form_state
[
'
redirect'
]
=
FALS
E
;
$form_state
[
'
no_redirect'
]
=
TRU
E
;
}
}
...
...
core/modules/system/tests/modules/form_test/src/Form/FormTestRedirectForm.php
View file @
18ddb004
...
...
@@ -9,6 +9,7 @@
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Url
;
/**
* Form builder to detect form redirect.
...
...
@@ -52,10 +53,12 @@ public function buildForm(array $form, FormStateInterface $form_state) {
*/
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
if
(
!
empty
(
$form_state
[
'values'
][
'redirection'
]))
{
$form_state
[
'redirect'
]
=
!
empty
(
$form_state
[
'values'
][
'destination'
])
?
$form_state
[
'values'
][
'destination'
]
:
NULL
;
if
(
!
empty
(
$form_state
[
'values'
][
'destination'
]))
{
$form_state
->
setRedirectUrl
(
Url
::
createFromPath
(
$GLOBALS
[
'base_url'
]
.
'/'
.
$form_state
[
'values'
][
'destination'
]));
}
}
else
{
$form_state
[
'
redirect'
]
=
FALS
E
;
$form_state
[
'
no_redirect'
]
=
TRU
E
;
}
}
...
...
core/modules/taxonomy/src/Form/OverviewTerms.php
View file @
18ddb004
...
...
@@ -341,7 +341,6 @@ public function buildForm(array $form, FormStateInterface $form_state, Vocabular
'#submit'
=>
array
(
array
(
$this
,
'submitReset'
)),
'#value'
=>
$this
->
t
(
'Reset to alphabetical'
),
);
$form_state
[
'redirect'
]
=
array
(
current_path
(),
(
$page
?
array
(
'query'
=>
array
(
'page'
=>
$page
))
:
array
()));
}
return
$form
;
...
...
core/modules/taxonomy/src/TermForm.php
View file @
18ddb004
...
...
@@ -98,10 +98,6 @@ public function form(array $form, FormStateInterface $form_state) {
'#value'
=>
$term
->
id
(),
);
if
(
$term
->
isNew
())
{
$form_state
[
'redirect'
]
=
current_path
();
}
return
parent
::
form
(
$form
,
$form_state
,
$term
);
}
...
...
core/modules/update/src/Form/UpdateManagerInstall.php
View file @
18ddb004
...
...
@@ -216,7 +216,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// whatever FileTransfer object authorize.php creates for us.
else
{
system_authorized_init
(
'update_authorize_run_install'
,
drupal_get_path
(
'module'
,
'update'
)
.
'/update.authorize.inc'
,
$arguments
,
$this
->
t
(
'Update manager'
));
$form_state
[
'redirect'
]
=
system_authorized_get_url
(
);
$form_state
->
setRedirectUrl
(
system_authorized_get_url
()
);
}
}
...
...
core/modules/update/src/Form/UpdateReady.php
View file @
18ddb004
...
...
@@ -141,7 +141,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
// whatever FileTransfer object authorize.php creates for us.
else
{
system_authorized_init
(
'update_authorize_run_update'
,
drupal_get_path
(
'module'
,
'update'
)
.
'/update.authorize.inc'
,
array
(
$updates
),
$this
->
t
(
'Update manager'
));
$form_state
[
'redirect'
]
=
system_authorized_get_url
(
);
$form_state
->
setRedirectUrl
(
system_authorized_get_url
()
);
}
}
}
...
...
core/modules/user/src/Plugin/Action/CancelUser.php
View file @
18ddb004
...
...
@@ -19,7 +19,7 @@
* id = "user_cancel_user_action",
* label = @Translation("Cancel the selected user accounts"),
* type = "user",
* confirm_form_
path = "admin/people/cancel
"
* confirm_form_
route_name = "user.multiple_cancel_confirm
"
* )
*/
class
CancelUser
extends
ActionBase
implements
ContainerFactoryPluginInterface
{
...
...
core/modules/user/src/RegisterForm.php
View file @
18ddb004
...
...
@@ -60,12 +60,6 @@ public function form(array $form, FormStateInterface $form_state) {
// Start with the default user account fields.
$form
=
parent
::
form
(
$form
,
$form_state
,
$account
);
if
(
$admin
)
{
// Redirect back to page which initiated the create request; usually
// admin/people/create.
$form_state
[
'redirect'
]
=
current_path
();
}
return
$form
;
}
...
...
core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
View file @
18ddb004
...
...
@@ -325,7 +325,6 @@ public function resetForm(&$form, FormStateInterface $form_state) {
$this
->
view
->
exposed_data
=
array
();
}
$form_state
[
'redirect'
]
=
current_path
();
$form_state
[
'values'
]
=
array
();
}
...
...
core/modules/views_ui/src/ViewEditForm.php
View file @
18ddb004
...
...
@@ -7,6 +7,7 @@