As part of the extensive changes made to path aliases in Drupal 8.8 (see the change records Path aliases have been converted to revisionable entities and The Path Alias core subsystem has been moved to the "path_alias" module, we have a lot of changes that need to be made to Rules AFTER Drupal 8.8 becomes the lowest supported version of core.

We already have two issues open for these changes:
#3088489: Path aliases have been converted to revisionable entities, fix when Drupal 8.8 becomes the lowest supported version
#3101026: Replace deprecated path.alias_manager and AliasManager when Drupal 8.8 becomes the lowest supported version

But there is one little fact hidden in that second change notice - in Drupal 8 the new 'path_alias' module is *required*, but in Drupal 9 it will be *optional*.

That poses a problem for Rules, because our Path condition and action plugins use the core Drupal path functions. These Rules plugins will always be available when Rules is enabled, even if the 'path_alias' is NOT enabled, but will crash Rules if 'path_alias' is not enabled. So we have a situation just like we had with the BanIp conditions and actions - we don't want to force sites to use the optional 'path_alias' module but we do want to give them Rules integration if they have it enabled, and the only way core provides us to deal with this dependency is to put our plugins in a submodule that depends on 'path_alias'.

Fortunately, this is something we can do right now, while we're still supporting D8.7. It's a lot of code movement, but not a lot of code modification. Almost entirely namespace changes. This will also make it easier to fix the above two issues, because all the code that needs to change will be isolated in a submodule. Let's see what the testbot says about this ...

Comments

TR created an issue. See original summary.

tr’s picture

StatusFileSize
new14.06 KB

Actually, I meant to compact that patch so the changes would be clear. I've aborted the above test, here's a better patch:

Status: Needs review » Needs work

The last submitted patch, 2: 3115367-2-rules_path_alias_module.patch, failed testing. View results

tr’s picture

Status: Needs work » Needs review
StatusFileSize
new17.09 KB

I thought I had put that missing part in there already, guess I forgot to git add it...

tr’s picture

Title: Move path conditions and actions into a new submodule » Add provider = "path_alias" to all path conditions and actions when Drupal 8.8 becomes the lowest supported version
Status: Needs review » Postponed

I've decided not to do this - it is not needed. See #3125443: Move rules_ban plugins back into Rules core for details.

The only thing needed here is that we should add provider = "path_alias" to all path conditions and actions, as described in the above issue. This will work in D8.8 and D9, but because the core "path_alias" module doesn't exist in D8.7 this change must be deferred until after D8.8 becomes the lowest supported version of Drupal core.

tr’s picture

tr’s picture

Status: Postponed » Active
tr’s picture

Status: Active » Needs review
StatusFileSize
new3.73 KB
tr’s picture

I think we're also going to have to explicitly enable the core path_alias module in any tests that use these path conditions/actions, in order for the tests to pass in D9.

tr’s picture

StatusFileSize
new8.83 KB

Here's a new patch that adds the path_alias module dependency to the tests. I think there is more to do with the Unit test, but only for the D9 case. And because mocking the path alias service is more a part of #3088489: Path aliases have been converted to revisionable entities, fix when Drupal 8.8 becomes the lowest supported version, I think I'll leave it to be fixed in that issue.

  • TR committed bd53746 on 8.x-3.x
    Issue #3115367 by TR: Add provider = "path_alias" to all path conditions...
tr’s picture

Status: Needs review » Fixed

Committed, with a coding standards fix.

jonathan1055’s picture

Thanks for this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.