Closed (outdated)
Project:
Views (for Drupal 7)
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 May 2011 at 21:25 UTC
Updated:
14 Mar 2019 at 17:55 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
becw commentedComment #2
merlinofchaos commentedIf using that validator, just use the User: UID argument instead. You'll get a better performing query, which is the whole reason for doing it.
Comment #3
becw commentedI want to have the user name in the URL, not the uid. The validator plugin will tranform a user name in the URL into a uid for the handler, which allows properly constructed URLs to work, but using an argument summary with the "User: UID" argument handler produces links with uids.
Removing this behavior from the validate plugin allows the "User: UID" argument handler to work when the validator is set to check for uids, and the "User: Name" argument handler to work when the validator is set to check for user names.
Unless the validator will intelligently transform the argument into the requested form (user name or uid), or preferably leave it untouched, it is broken.
Comment #4
becw commentedComment #5
merlinofchaos commentedThe validator will accept a user name, and transforms it into a uid.
The URL will still be a name, because the validator accepts a name. Since it looked up the name and has a uid, using a uid in the query performs better.
Comment #6
becw commentedThe "User: UID" argument handler won't build summary links that include a username.
Comment #7
merlinofchaos commentedIn that case, I guess you can't use the validator.
I will not be committing this patch.
Comment #8
merlinofchaos commentedThe reason I won't commit this patch is that it will break all existing arguments that are currently set up this way. Plus, it is totally the intended behavior. The issue, then, is that the validators don't currently participate in the summary argument creation, which has always been an issue that I've wanted to fix, and this isn't the fix for it.
Comment #9
becw commentedSo the validator is not usable for this argument handler. Ah, well.
Thanks for your response in #8. I appreciate you putting a moment into something that is, for you, a non-issue.
Comment #10
merlinofchaos commentedI would like to fix it so that validators can participate in the summary building process. The way Views 3.x works, it actually should be relatively easy. There just needs to be a method on the validator that the argument can call to reverse the transformation, and then the validator needs to support transformation in both directions.
Comment #11
becw commented@dereine -- here's an example view.
Comment #12
dawehnerSo here is a patch.
The patch has quite some todos:
* move the altering of the arguments out of the theme preprocess function, it's wrong there and has to be copied to work
* Find better function names, this doesn't seem to be the right one at the moment.
The only positive thing is that it works.
Comment #13
becw commentedSo, as you say, this patch has several issues. At the very least, we can not use the standard
$var = &drupal_static(__FUNCTION__)pattern in an argument handler method, since__FUNCTION__does not yield a variable name specific to this implementation of this method (so that argument handlers using different validators would end up using the same validator plugin); instead, a specific instantiation of the validator plugin should be stored as a property on the object.My main problem with this patch, though, is that this code duplicates the purpose of an existing method:
views_handler_argument::summary_argument(). I see that this is done for efficiency reasons--an argument handler's::summary_argument()method is run for every link in the summary--but we could easily build all the url arguments on the first run of::summary_argument()and then return the correct pre-built argument on each subsequent call. And really, how can one talk about efficiency and then runuser_load_multiple()?In this case, the argument we wish to use is already present--it is the 'name field' from the summary query. By changing the field alias used in retrieving the summary argument in
views_handler_argument::summary_argument(). I've implemented this approach in the attached patch. The obvious issues with this patch are:views_handler_argument_user_uidthat checks whether the 'user' validator is in useEven if this feature were implemented in a way that refers to the the validator plugin for transformation, the argument handler's
::summary_argument()method should ultimately be used to pass the correct summary link argument to the theme layer.Comment #14
dawehnerPlease don't look at any kind of views which involves any kind of fieldapi data you will cry ...
Will review this tomorrow.
In general this patch does not provide this nice way to get the original input of an argument which earl suggested,
but your patch seems to be much simpler.
Comment #15
dawehnerBetter title
Comment #16
dawehnerWe had quite some discussions on irc around this topic.
As result it will be more like patch #12 because we can't rely on the data availible in a summary_alias.
Comment #17
dawehnerNew name: process_summary_arguments
Comment #18
dawehnerOkay here is a new version which
* keeps the things in the preprocess, because that's not really such bad and there aren't many summary plugins in the wild
* renamed the function and changed the comments a bit.
@becw:
Please test the patch.
Comment #19
becw commentedThis patch mostly works. There are two remaining issues:
&drupal_static(__FUNCTION__)pattern in an argument handler method (see my comment #13 above). I've rerolled the patch with this change.::summary_argument()method directly, which will yield bad URLs if used with the user argument validator 'username' setting--so this issue is still present when using the "jump menu" summary style. I've added a @TODO to this rerolled patch, but I haven't actually come up with a solution here.Comment #20
dawehnerups the first one was left.
About the second one, here is an update of the patch, which works for this view:
Comment #21
becw commentedLooks good!
One last request: can we add a
::process_summary_arguments()method for the taxonomy term validator plugin, too? I've rolled it into the patch, which is my only change from #20.Comment #22
dawehnerCommited to 7.x-3.x
This needs some rerole because there is dbtng involved.
Comment #23
dawehnerJust realized during porting the vocabularies can't be defined at this scope.
Let's get this first fixed in d7 and backport everything.
Comment #24
dawehnerHere is a patch for the fix of the bug.
Comment #25
dawehnerOkay commited so let's concetrate on the backport.
Comment #26
chris matthews commentedThe Drupal 6 branch is no longer supported, please check with the D6LTS project if you need further support. For more information as to why this issue was closed: #3030347: Plan to clean process issue queue