Problem/Motivation

ConditionManager uses the ContextAwarePluginManagerTrait, which contains the public method getDefinitionsForContexts().
However, that method isn't backed by any interfaces.

Most code uses ExecutableInterface, which is only a subset of the methods available.

Proposed resolution

Add a ConditionManagerInterface that implements both ExecutableManagerInterface and ContextAwarePluginManagerInterface
Use that interface for typehinting throughout

Remaining tasks

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because this is a job several developers agreed needed doing.
Issue priority Normal because this is not necessary for launching an RC right now.
Disruption It should not be disruptive for contributed modules because if they happen to rely on the implementation, they will continue working. There is potential for disruption in core, which of course would affect the contrib world if there is something missed or if test coverage is incomplete.

Comments

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new10.21 KB
xano’s picture

StatusFileSize
new10.54 KB

Re-roll.

fago’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, makes a lot of sense - the interface is really missing. Introducing it now should be fine also, as all existing code referring to the ExecutableInterface will continue to work.

jibran’s picture

Can we add beta eval quickly here?

webchick’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs beta evaluation

Xano queued 2: drupal_2385427_2.patch for re-testing.

fago’s picture

Status: Needs review » Needs work
cilefen’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs beta evaluation

I added a beta eval. Having done that, I believe this should be postponed to the next release.

xano’s picture

This patch does not break anything, but reduces fragility. Disruption is minimal, but we can completely eliminate any disruption by removing the type hint changes from the patch.

I'd like to add this at the earliest possible moment, for increased DX, documentation, and testability.

Xano queued 2: drupal_2385427_2.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 2: drupal_2385427_2.patch, failed testing.

cilefen’s picture

Status: Needs work » Needs review
StatusFileSize
new10.26 KB

Rerolled #2.

Xano queued 12: add_a-2385427-12.patch for re-testing.

Xano queued 12: add_a-2385427-12.patch for re-testing.

xano’s picture

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

Status: Needs review » Needs work

The last submitted patch, 12: add_a-2385427-12.patch, failed testing.

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new9.8 KB

Re-roll.

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

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now 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.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now 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.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.

jhedstrom’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Condition/ConditionManagerInterface.php
@@ -0,0 +1,20 @@
+/**
+ * @file
+ * Contains \Drupal\Core\Condition\ConditionManagerInterface.
+ */

This bit can be removed as these file comments are no longer needed.

Everything else looks good.

Vidushi Mehta’s picture

Status: Needs work » Needs review
StatusFileSize
new9.18 KB

Added a rerolled patch as the previous patch does not apply on current version.

Status: Needs review » Needs work

The last submitted patch, 25: rerolled-2385427-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new7.66 KB

Re-roll, and this implements the feedback from #24.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Makes more sense now, patch looks good.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/block/src/BlockForm.php
@@ -96,7 +96,7 @@ class BlockForm extends EntityForm {
-  public function __construct(EntityManagerInterface $entity_manager, ExecutableManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_manager) {
+  public function __construct(EntityManagerInterface $entity_manager, ConditionManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_manager) {

This is a BC breaking change. We need to leave the typehint alone and trigger a silenced deprecation if $manager does not implement ConditionManagerInterface

xano’s picture

+++ b/core/lib/Drupal/Core/Condition/ConditionManager.php
@@ -71,6 +68,7 @@ public function createInstance($plugin_id, array $configuration = []) {
+    /** @var \Drupal\Core\Condition\ConditionInterface $condition */

Should we enforce this type in a similar fashion, by triggering an error?

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new4.19 KB
new7.91 KB

This implements @alexpott's feedback from #29, and adds a few small clean-ups.

xano’s picture

StatusFileSize
new893 bytes
new7.04 KB

Let's undo this docs change that isn't actually enforced (we keep BlockForm as a proof-of-concept implementation of the change).

longwave’s picture

+++ b/core/modules/block/src/BlockForm.php
@@ -97,6 +98,9 @@ class BlockForm extends EntityForm {
+      @trigger_error(printf('The condition manager should implement %s. Merely implementing %s has been deprecated since Drupal 8.7.0.', ConditionManagerInterface::class, ExecutableManagerInterface::class), E_USER_DEPRECATED);

I think this should follow the standard format, ie. "Implementing ExecutableManagerInterface in condition managers is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use ConditionManagerInterface instead. See http://drupal.org/node/xxx" - we also need a change notice for this.

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

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.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.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jhedstrom’s picture

Status: Needs review » Needs work

Setting to NW for #33.

tim.plunkett’s picture

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

Now that 8.8 is out, it's going to be deprecated in 9.1 and removed in 10.0

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.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.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.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.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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.

andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new6.5 KB

re-roll for 10.1

anchal_gupta’s picture

StatusFileSize
new6.7 KB
new528 bytes

Fixed CS error

Status: Needs review » Needs work

The last submitted patch, 44: 2385427-44.patch, failed testing. View results

Version: 10.1.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, which currently accepts only minor-version allowed changes. 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.