I've run in to a major issue with Pathauto where as soon as you try and add in a new Pattern that only targets a specific content type, it throws the following error:
The website encountered an unexpected error. Please try again later.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node_type" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Digging around I found a somewhat related isse over on Ctools: https://www.drupal.org/project/ctools/issues/2638380
But I'm using a much newer version of the module so I wouldn't think it would be the cause of this issue.
Setup:
* Drupal 8.39
* PathAuto 1.0+3-dev
* CTools 8.3
* Token 1.0
And according to the release notes, required should be:
ctools 8.x-3.0
token 8.x-1.0
so we should be right.
Steps to reproduce
* Create a new Pattern via /admin/config/search/path/patterns
* Make the Pattern Type = "Content"
* Set whatever settings and titles you want and select just one content type for it to apply to
* Try and save the pattern
* See error message, changes to the pattern are not saved
Issue fork pathauto-2925169
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
marblegravy commentedMore testing has shown that this is a conflict with another module somewhere in the mix.
Installing a fresh site with only PathAuto, Ctools and Token does not replicate the issue.
More digging required. If anyone has any ideas though I'd be happy to hear them!
Comment #3
daniel_j commentedUpstream CTools has removed the
node_typeplugin, and replaced it with derivatives ofentity_bundle. If you export your config, you can search-and-replace on all yourpathauto.pattern.*.yml, changing references tonode_typetoentity_bundle.node.See https://www.drupal.org/project/ctools/issues/3300682
Comment #4
rajab natshahThank you, Daniel for the hint in
https://www.drupal.org/project/pathauto/issues/2925169#comment-14635641
Not sure if a generic hook update for this could follow on entity types with patterns
Doing that on needed entity types
Comment #5
berdirThere is an update function for these, but an update can only deal with existing config on existing sites, it can't fix default content in modules and install profiles.
This is the pathauto version of https://www.drupal.org/node/2983299. Help to create a custom change record for pathauto would be welcome.
Note that there is an awkward grey area for install profiles that already updated to the pathauto version that includes the update function but did not update their default content at the same time, because for these sites, that update did not run. In that case, you want to copy pathauto_update_8108() into your install profile so it runs again (with your own name and update number of course).
Comment #6
berdirAlso, note that the original issue was from 2017 here, which I can't see how that's the same issue.
Comment #7
berdirAnd second note, I don't quite understand why the ctools update caused this. node_type is provided by core, ctools just extend it, it should not cause it to be removed entirely.
Comment #8
daniel_j commented@Berdir, regarding your remark in #7: After the ctools update a derived plugin class is substituted for core's non-derived
node_typeplugin. As a result, core sees that it implements the derived interface and attempts to get the derivative ID from the plugin ID, and since it does not contain a colon, returns NULL.Prior to CTools 3.10, it simply used the core class, and did not substitute the derived class.
Comment #9
rajab natshahThank you, Sascha for the hint <3 about updating profiles with
pathauto_update_8108Recalling its content after updating the default configs.
To make sure that the change of active config will not be missed.
Comment #10
damienmckennaThis could be fixed by cloning pathauto_update_8108() and adding a message instructing site maintainers to export the configuration after the changes run.
Comment #11
berdirChanging to a fixed support request. The ctools bug is being fixed in the ctools issue, see also https://www.drupal.org/project/pathauto/releases/8.x-1.11.
Comment #12
WebbehDocumenting this from the ctools issue:
Per #3300682-39: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context.:
Per #3300682-41: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context.:
And #3300682-43: [error] Drupal\Component\Plugin\Exception\ContextException: The context is not a valid context.:
Comment #14
alexandersluiter commented#12 Just saved me. Thank you!
Comment #15
jeffc518 commentedI looked at @daniel_j's comment first (#3) which was spot on, except for one minor thing:
you can search-and-replace on all your pathauto.pattern.*.yml, changing references to node_type to entity_bundle.node.It should be
entity_bundle:nodePer example, in a pathauto.pattern.page_by_menu.yml, mine was:
but should be:
.. assuming it's a node of course.
Comment #16
loopy1492 commentedThank you so much @JeffC518!!!!
This cropped up during our Drupal 10 upgrade.
We run `blt install:drupal` during ci build on the server and when it tried importing these into a fresh database, it choked and died with the OP's error. Changing the slection_criteria id to entity_bundle:node solved it.
Comment #17
coaston commentedHi,
Where exactly is has to be changed ? I dont see any pathauto.pattern.* yaml files with already mentioned code :
Does not wotk for d10
Comment #18
coaston commentedEdit . It works now. I had to change it in different module, Not here in pathauto.
Comment #19
gshreegs commentedHi @coaston, which module did you change it in? I'm facing a similar thing
Comment #20
coaston commentedHi gshreeGs
in my case it was triggered by different module View Mode Page and this fix resolved it :3300706
However it is connected somehow with CTools as described in #12 so the best way for you is to go to Admin > extend > Chaos Tools and see which of your contrib modules use it (Required by:) and I am sure that one of this modules have to be updated as they are not ready for D10.
Comment #21
fadonascimento commentedThanks @Webbeh #12 Helps me a lot!
Comment #23
javitan commentedFor some reason the after upgrading the core and module it didn't update my pattern files, so you will need to change them manually (pathauto.pattern.YOURNODE.yml).
So just change the id from this:
Into this:
It fixed the problem for me. Good luck!
Comment #24
othmen commentedThanks @javitan.
#23 resolved my problem.
Comment #25
earthangelconsulting commented#23 worked for me too. thanks!
Comment #26
thirstysix commentedafter update, it works well.
config sync file: pathauto.pattern.workshop.yml
from
id: node_typeto
id: entity_bundle:noderun drush cim
solved! Thanks #23