This module contains a plugin which makes use of ContextAwarePluginBase which was deprecated after Drupal 9.1 and removed in Drupal 10, this has been re-written in the pathauto module to use the ContextAwarePluginTrait which this module looks to be based off, so I would suggest that this module should do the same.

Comments

andy_w created an issue. See original summary.

andy_w’s picture

StatusFileSize
new1.22 KB
andy_w’s picture

Status: Needs work » Needs review
andy_w’s picture

Title: Drupal 10 compatibility with ContextAwarePluginBase (now removed) » Drupal 10 compatibility
StatusFileSize
new1.94 KB
new739 bytes

Additional to this Drupal 10 also requires all queries explicitly set accessCheck as part of the query (see https://www.drupal.org/node/3201242) therefore the request to fetch all view_mode_page_patterns requires ->accessCheck(TRUE) to support Drupal 10.

jerrac’s picture

I just found this module and was trying it out on a new D10 site. Since I ran into the ContextAwarePluginBase error, I tried patching via Composer/cweagans/composer-patches.

The 3356400-drupal-10-compatibility.patch file lets me see and use the full Add Pattern form, but when I submit, I get this error:

The website encountered an unexpected error. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist. Valid plugin IDs for Drupal\Core\Condition\ConditionManager are: request_path, current_theme, user_role, entity_bundle:block_content, entity_bundle:comment, entity_bundle:feeds_feed, entity_bundle:media, entity_bundle:menu_link_content, entity_bundle:node, entity_bundle:shortcut, entity_bundle:taxonomy_term, entity_bundle:paragraph in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 59)
Drupal\Core\Condition\ConditionManager->createInstance() (Line: 81)
Drupal\Core\Plugin\DefaultLazyPluginCollection->initializePlugin() (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get() (Line: 26)
Drupal\Core\Condition\ConditionPluginCollection->get() (Line: 160)
Drupal\Core\Plugin\DefaultLazyPluginCollection->setInstanceConfiguration() (Line: 172)
Drupal\Core\Plugin\DefaultLazyPluginCollection->addInstanceId() (Line: 294)
Drupal\view_mode_page\Entity\ViewmodepagePattern->addSelectionCondition() (Line: 264)
Drupal\view_mode_page\Form\PatternEditForm->buildEntity() (Line: 170)
Drupal\Core\Entity\EntityForm->afterBuild()
call_user_func_array() (Line: 1083)
Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 579)
Drupal\Core\Form\FormBuilder->processForm() (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 686)
Drupal\Core\DrupalKernel->handle() (Line: 19)

If I try to apply the interdiff.txt file alongside the .patch file, it fails to patch.

If I try the interdiff.txt file on it's own, the full Add Pattern form does not show up, and I get another error. (That I failed to copy, sorry.)

That's the end of my testing. Hope it might help.

Edit: Forgot my system info...
Drupal 10.0.9. View Mode Page 4.0.2. PHP 8.1.

andy_w’s picture

StatusFileSize
new3.36 KB
new1.42 KB

Thanks for identifying this issue jerrac, I have updated the patch now that the node_type condition has been removed (see https://www.drupal.org/project/drupal/issues/1932810)

anybody’s picture

james.williams’s picture

There are differences between the two patches. This one adds an access check to an entity query. The entity query is for config entities, so the access check is not actually strictly necessary, but it does no harm to add it (and adding it will stop static analysis from unnecessarily flagging it up). On the other hand, this one does not account for 'entity_bundle' as the plugin ID... I don't know if that's OK or not.

chrisdarke’s picture

Looks like all these changes were applied to 4.0.3, can someone please mark this one as Closed (Fixed) because I was just going through checking why the patch no longer applies un-necessarily.

raphaelbertrand’s picture

it seems that at least the part on /src/Form/PatternEditForm.php by @andy_w is not yet in 4.0.3 as the error still happen

Drupal\Component\Plugin\Exception\PluginNotFoundException : The "node_type" plugin does not exist. Valid plugin IDs for Drupal\Core\Condition\ConditionManager are: is_archive, response_code, language, request_path, response_status, current_theme, user_role, webform, entity_bundle:block_content, entity_bundle:comment, entity_bundle:media, entity_bundle:node, entity_bundle:redirect, entity_bundle:shortcut, entity_bundle:taxonomy_term, entity_bundle:webform_submission, entity_bundle:menu_link_content, entity_bundle:paragraph dans Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (ligne 53 de /web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

raphaelbertrand’s picture

on #3300706: Context exception when trying to create url (Drupal 10 is broken!)
there is a patch and MR waiting for merging wich solve the remaining issue.