Closed (fixed)
Project:
Pathauto
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
19 Feb 2016 at 20:50 UTC
Updated:
25 Jul 2016 at 18:24 UTC
Jump to comment: Most recent, Most recent file
See #2672142: Update assertAlias() to use alias manager so it works with 8.1.x
Pathauto has quite a few direct queries against {url_alias}.
Someone might want to move that to a different storage, e.g. MongoDB and then pathauto would break.
We should evaluate them and try to get rid of them, possibly try getting support for e.g. IN conditions for load() into core.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | use_alias_manager_and-2672150-10.patch | 12 KB | Bambell |
Comments
Comment #2
sharique commentedI did some work on it, replaced query with helper at few places, please review and let me know, if this is correct way.
Comment #3
Bambell commentedI tried refactoring
AliasStorageHelper, but didn't end up doing much. I simplifiedloadBySource(); the original implementation would return the alias for a given source path and language and would fallback to undefined language if nothing was found, but I'm not sure this behavior is appropriate. I changed this to simply query for an exact match for the given language. I also removed unused functionexists()and broke down functions that supported the wildcard character*.url_aliasis now referenced only intruncate(),loadBySourcePrefix(),countAliasesBySourcePrefix()andcountAliasesBySourcePrefix(). The reference inloadBySourcePrefix()(and potentially more) could be eliminated and the code greatly simplified if core wouldn't escape the value being matched inDrupal\Core\Path\AliasStorage::delete():$query->condition($field, $this->connection->escapeLike($value), 'LIKE');Not sure why they're doing that. It prevents using
%. Same forload().Other than that, I'm not seeing much more room for improvement, as far as I can tell.
Comment #4
sharique commentedMy 2 cent point, instead of truncate, better name it deleteAllAliases, for simple to understand, what function does with name.
Comment #5
berdirThe problem is that we already have deleteAll(). deleteAll() and deleteAllAliases() doing something different wouldn't make sense.
What we could do is rename the current deleteAll() to deleteBySourcePrefix() because that's what it does and then have deleteAll() actually delete all.
the behavior with langcode and fallback is important, we can't just remove that. Because that's how the system works when resolving an alias, it first checks the current language then falls back to language-unspecific.
since the class is called AliasStorageHelper and most methods don't have Alias in the name, I think we should be consistent and always leave it out.
Comment #6
Bambell commentedMakes sense. I renamed
truncate()todeleteAll()anddeleteAll()todeleteBySourcePrefix(). I added fallback to undefined language forload()and renamed some other functions as well. I moved the visibility ofdeleteMultiple()frompublictoprotected, because the interface is already a bit confusing, in my opinion, and I can't think of a use case for this outside of the class (there is no operation to get multiplepid's). Moved some other things around as well.Comment #7
berdirjust int, not integer.
space after (string)
Looks good to me. One thing that I think we should also do here is to add the backend_overridable tag to the storage helper service in services.yml, see https://www.drupal.org/node/2306083. That makes it easier for e.g. redis to provide an alternative backend.
Comment #8
Bambell commentedHere we go.
Comment #9
berdirLooks good but waited too long, needs a reroll now.
Comment #10
Bambell commentedHere we go, re-rolled.
Comment #11
Bambell commentedComment #12
berdirThanks, committed.