Postponed (maintainer needs more info)
Project:
Drupal core
Version:
main
Component:
database system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
25 Mar 2010 at 18:31 UTC
Updated:
28 Jul 2026 at 21:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
berdirThe test validates currently something slightly different, bug #3 from the initial posting in #467984: DBTNG bugfixes to be exact. Basically, that means that it failed completely before my fix, because the code did not recognise the "PagerDefault" class as a SelectQuery as it used "instanceof SelectQuery" instead of "instanceof SelectQueryInterface".
Obviously, this is broken too and once there is a bugfix, the test can be easily expanded to test for this bug too. I'll try to look into this.
Comment #2
berdirOk, I found the bug and fixed the test, but I don't have a solution yet.
The problematic part is this part:
However, PagerDefault does add its stuff in an overidden execute() method. By casting the query directly to a string, we never call execute().
I'm not sure how to fix this in a way that avoid similiar bugs in the future. Just changing PagerDefault might not be enough. The first thing that comes to my mind is making th execute() method final and try to find other ways to add the stuff to our query. That would also make all that complicated stuff to avoid calling things multiple times unecessary. But I'm not sure if we can do this at this point.
Comment #3
berdirComment #5
damien tournoud commentedI don't believe there is any way to properly support that. There are basically two types of query extenders: those that do something nasty on execute(), those that don't. I suggest we just find a way to make sure that we raise an exception at one point if one tries to use an extender that has to do something nasty on execute() in a subquery.
Comment #6
berdirDo we even need that nasty execute stuff?
The pager test passes now, let's see what the other tests are saying...
Comment #7
berdirComment #8
damien tournoud commentedYes we need that nasty execute stuff.
The only function that can have a side effect is execute(). The others are supposed to be passive functions only.
Comment #9
berdirOk, discussed this with DamZ...
- We separate query extenders into good and bad. This is done by adding a new hasExecute() method to SelectQueryExtender which is called recursively and defaults to FALSE. if an extenders needs execute() to work correctly he is supposed to override that method and return TRUE.
- We need such a method and can't rely on reflection because of the recursion. $query->extend('SearchQuery')->extend('AGoodExtender') will not have an overriden execute() method in the top-level, but can't be used as a subquery because of the Search extender.
- SeachQuery is definitly a nasty query, TableSort is not.
- We are not yet sure if PagerDefault can be converted to a good query but I think it can because of the reasons outlined above (can be overriden/called multiple times and only range() is called, no irreversible action happens)
Let's see if the tests pass now. Thoughts on the general approach?
The comments and tests can probably be improved...
Comment #11
berdirDiffed against a wrong version...
Comment #12
berdirWell, that happens if you write patches in vi and don't even do a basic php syntax test.. ;)
Comment #14
berdiranother try...
- Added a check so that we only call hasExecute(() on extended queries
- Overriden the countQuery() method in SearchQuery so that we don't need to do it in node_search_submit() because that's not possible with the new exception anymore.
Comment #15
sunException thrown if an extended query overriding execute() is used as subquery.
This summary doesn't map to the function body -- at least it rather sounds like a advanced description, not a summary about what this function is doing.
I tried to rephrase this sentence, but wasn't able to understand it.
Also, trailing white-space here.
Trailing white-space here.
wow. Not sure what this construct is actually doing, but a short comment would be helpful, since this looks quite weird.
Powered by Dreditor.
Comment #16
berdirThanks for the review, this was more a proof of concept so the comments were bad :)
Really need to point Crell to this....
Anyway, here is a re-roll with the comments updated. Is it more clear now? The Zero-out stuff already existed, I just copied that to SearchQuery.
Comment #17
Crell commentedUm. I'm still kinda confused. :-)
Can someone explain to me 1) What exactly the issue is here and 2) Why we need an extra method? Can't we use reflection to determine if a class overrides execute()?
Comment #18
berdir1) We do not call execute() on a SelectQueryInterface object when using it as a subquery of another query. This means that extended queries which override execute() and do stuff in there don't work as expected. (That we are not calling the alter hook of subqueries is a similiar bug which is addressed in another issue).
2) I'm happy to be proven otherwise, but I don't think so. Since we are using the Decorator-Pattern, there could be two different decorators and only the inner overrides execute() (Example: A -> B -> C, B overrides execute()). I don't think we can reliably detect this with reflection. The method allows us to bubble up until either a decorator returns TRUE or we reach the SelectQuery object.
Comment #19
Crell commented1) OK, I think I follow now. When would we actually be doing that, though? I cannot think of a case where we'd want a tablesort or pager query as a subquery. What's wrong with documenting "dude, seriously, don't do that, it's dumb"?
2) What about checking with this: http://us2.php.net/manual/en/reflectionmethod.getdeclaringclass.php
Also changing title so have a space in it somewhere so it doesn't screw up the issue listing page... :-)
Comment #20
moshe weitzman commentedBased on last comment, lets downgrade this. If anyone disagrees, feel free to return to critical with a justification
Comment #21
webchickThis issue is rated as critical #791270: SearchQuery exact search conditions not added to CountQuery. Berdir recommends fixing this instead. Crell, does that give you the use case you're looking for on this, or..?
Comment #22
berdirSee my comment in the other issue, the part that is relevant for the linked issue above is only a necessary side effect of the changes proposed in this patch, I only suggest to move these changes to the other issue since they help to simplify the usage and avoid bugs for modules using SearchQuery.
Comment #23
berdir#16: nasty_or_good5.patch queued for re-testing.
Comment #25
Crell commentedI don't think this can be fixed in the D7 cycle, if at all. The linked issue apparently got fixed already.
Comment #26
agileware commentedDoes this issue also cover the case of a query with a subquery in a condition which is then used with the pager. Because that also doesn't work.
Comment #33
andypostComment #43
luke.stewart commentedCurrently the least recently updated core issue that is active or needs work.
Apart from an issue summary update this was last engaged with a long long long time ago.
Given this I'm going to mark this as PMNMI.
If it's still a problem that should be address please set it back to needs work.
Otherwise I think this could be closed in 3 months.