Problem/Motivation

It is possible to delete the default shortcut set by running

shortcut_default_set()->delete();

This leaves Shortcut module (and by extension the entire website) in a completely broken set. For example, just by visiting /admin/config/user-interface/shortcut or /user/%/edit you will see a fatal.

Proposed resolution

Thrown an exception when trying to delete the default shortcut set.
Specifically implement \Drupal\shortcut\Entity\Shortcut::preDelete(), loop over the passed $entities and check whether any of them has $entity->id === 'default' and if so, throw a \BadMethodCallException. This will also need tests.

Remaining tasks

User interface changes

None.

API changes

None.
Technically an added exception is an API change, but if someone tried to do this previously this was undoubtedly by accident and they would certainly have liked to be warned.

Original report by @chx

Although I made an oath to never use the default profile, testing uses it and spits notices at me. (Of course. That's why I do not use it.) I still keep my word tho and never actually look at it :p

CommentFileSizeAuthor
shortcut_set_empty.patch4.07 KBchx

Comments

David_Rothstein’s picture

How did you wind up with no shortcut set? This shouldn't be possible without hacking the database; shortcut_current_displayed_set() is AFAIK always guaranteed to return something. I also haven't seen any notices running tests...

Can you explain more how to reproduce this bug?

yoroy’s picture

If you delete all shortcuts from the default set, then save changes you get

Notice: Undefined index: shortcuts in shortcut_set_customize_submit() (line 314 of /Users/yoroy/Sites/d7/modules/shortcut/shortcut.admin.inc).
Warning: Invalid argument supplied for foreach() in shortcut_set_customize_submit() (line 314 of /Users/yoroy/Sites/d7/modules/shortcut/shortcut.admin.inc).

Shown only on saving changes to the set, not on other admin pages.

catch’s picture

Priority: Critical » Normal

Looks like a valid bug but this isn't critical.

David_Rothstein’s picture

Status: Needs review » Postponed (maintainer needs more info)

@yoroy's bug is definitely reproducible, but it's not the same as the original issue. The issue @yoroy reported here was later reported at #937380: errors when submitting the shortcut set configuration page after deleting all shortcuts, and since that is a dedicated issue for it, I posted a patch to fix it there.

I'm setting this one to "needs more info". I still don't know how to reproduce the original bug report except by hacking the database.

yoroy’s picture

Version: 7.x-dev » 8.x-dev

Bump to d8. I didn't verify if the issue still exists.

tstoeckler’s picture

Title: If there is no shortcut set, shortcut spits notices everywhere » Deleting the default shortcut set from the API should throw an exception
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active
Issue tags: +Needs backport to 7.x

I found that it is in fact possible to delete the default shortcut set from the API, so repurposing this issue for preventing that.

xjm’s picture

Issue tags: -Needs backport to 7.x +Needs backport to D7

 

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
catch’s picture

Category: Bug report » Task

We don't really stop people from deleting things in the API usually, so moving this to a task. This could break code that's deleting the default, then adding a new default. Feels like it's really up to calling code to check first.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Active » Postponed

The Shortcut Module was approved for removal in #3476880: [Policy] Move Shortcut module to contrib.

This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3569117: [meta] Tasks to deprecate the Shortcut module and the removal work in #3569121: [meta] Tasks to remove the Shortcut module.

Shortcut will be moved to a contributed project before Drupal 12.0.0 is released.