diff -u b/core/modules/user/lib/Drupal/user/ProfileFormController.php b/core/modules/user/lib/Drupal/user/ProfileFormController.php --- b/core/modules/user/lib/Drupal/user/ProfileFormController.php +++ b/core/modules/user/lib/Drupal/user/ProfileFormController.php @@ -7,22 +7,37 @@ namespace Drupal\user; +use Symfony\Component\HttpFoundation\Request; + /** * Form controller for the profile forms. */ class ProfileFormController extends AccountFormController { + /** + * {@inheritdoc} + */ + public function buildForm(array $form, array &$form_state, Request $request = NULL) { + $this->request = $request; + return parent::buildForm($form, $form_state); + } + /** * Overrides Drupal\Core\Entity\EntityFormController::actions(). */ protected function actions(array $form, array &$form_state) { $element = parent::actions($form, $form_state); + + // The user account being edited. $account = $this->entity; + // The user doing the editing. + $user = $this->request->attributes->get('_account'); + $element['delete']['#type'] = 'submit'; $element['delete']['#value'] = t('Cancel account'); $element['delete']['#submit'] = array(array($this, 'editCancelSubmit')); - $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $GLOBALS['user']->id() && user_access('cancel account')) || user_access('administer users')); + $element['delete']['#access'] = $account->id() > 1 && (($account->id() == $user->id() && $user->hasPermission('cancel account')) || $user->hasPermission('administer users')); return $element; } @@ -44,16 +59,16 @@ /** - * Submit method for the 'Cancel account' button. + * Provides a submit handler for the 'Cancel account' button. */ public function editCancelSubmit($form, &$form_state) { $destination = array(); - $query = Drupal::request()->query; + $query = $this->request->query; if ($query->has('destination')) { - $destination = drupal_get_destination(); + $destination = array('destination' => $query->get('destination')); $query->remove('destination'); } // Note: We redirect from user/uid/edit to user/uid/cancel to make the tabs disappear. - $account = $form_state['controller']->getEntity(); - $form_state['redirect'] = array("user/" . $account->id() . "/cancel", array('query' => $destination)); + $account = $form_state['controller']->entity; + $form_state['redirect'] = array('user/' . $account->id() . '/cancel', array('query' => $destination)); } } only in patch2: unchanged: --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -348,11 +348,6 @@ function testTermInterface() { // Check that the term feed page is working. $this->drupalGet('taxonomy/term/' . $term->id() . '/feed'); - // Check that the term edit page does not try to interpret additional path - // components as arguments for entity_get_form(). - $this->drupalGet('taxonomy/term/' . $term->id() . '/edit/' . $this->randomName()); - $this->assertResponse(200, 'The taxonomy term edit menu item ensured appropriate arguments were passed to its page callback.'); - // Delete the term. $this->drupalPost('taxonomy/term/' . $term->id() . '/edit', array(), t('Delete')); $this->drupalPost(NULL, NULL, t('Delete'));