Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Probably an easy one.
Comment | File | Size | Author |
---|---|---|---|
#21 | trigger-dbtng3.patch | 8.71 KB | andypost |
#19 | trigger-dbtng2.patch | 8.7 KB | andypost |
#16 | trigger-dbtng.patch | 8.72 KB | andypost |
#7 | trigger.module-1.patch | 8.49 KB | csevb10 |
#5 | trigger.module-1.patch | 8.33 KB | csevb10 |
Comments
Comment #1
phoolish CreditAttribution: phoolish commentedComment #2
phoolish CreditAttribution: phoolish commentedComment #3
Crell CreditAttribution: Crell commentedComment #4
csevb10 CreditAttribution: csevb10 commentedCertain aspects still need to be rewritten.
Elements like this
should be rewritten to use the new replacement syntax.
In addition, db_query return an object that can be iterated over, so this
can be rewritten as a foreach that iterates over the $result object.
Comment #5
csevb10 CreditAttribution: csevb10 commentedRe-roll of the trigger module patch with modifications for db_query calls.
Comment #6
Crell CreditAttribution: Crell commentedThat line is way too long to be pretty. :-) Let's split the query out from the if statement so that we can break out the placeholders array vertically, save to a variable, and then if() on that.
This should also be spread out to multiple lines. Any time you have more than one placeholder the array should be broken out vertically. There are a couple such queries.
In almost all cases, a result set should be named $result to avoid confusion. Only give it a name when there's a couple of active result sets operating at once. (See _trigger_get_hook_aids())
Comment #7
csevb10 CreditAttribution: csevb10 commented1 step closer every time, that's what I say. Sooner or later, I'll just do it right the first time.
I reformatted the queries to break across lines, but I still wasn't 100% sure how to format 1 aspect:
Would you like the array indented more and the fetchField in its current location, or is this format the preferred format?
Comment #8
catchThe straight select queries/db_query() should just be on one line, no need to split the array for those. Otherwise looks good.
Comment #9
Crell CreditAttribution: Crell commentedActually if there's 2 or more placeholders, the placeholders array should be multi-line.
That has no need to be dynamic, though. Otherwise it looks fine.
Comment #10
BerdirThere are two possible ways to indent, I'd prefer B) because we actually do chaining, even if it's only a single method and because the statement is not finished.
A) This is used if the statement is finished after the closing array, for example in hook_menu()
B) This is used in chaining, when there are multiple chaining methods
Comment #11
Crell CreditAttribution: Crell commentedI believe most of core is already using A.
Comment #12
BerdirOk, we pretty much agreed on the following coding style:
So the following needs to be updated, the rest of the patch looks good.
Comment #13
Crell CreditAttribution: Crell commentedUm, how do you get from "most of core is already doing A" to "let's do B"? Where did "we pretty much agree" on changing it?
Comment #14
catch@Crell - http://drupal.org/node/456824#comment-1596042
Comment #15
BerdirSeems I copied the wrong example, I meant A. What I wanted to point out is that fetchField() should be on the same line. Updated the above comment.
Comment #16
andypostHere reroll after #246096: Cron triggers are not executed
With modifications from #12
Comment #17
Crell CreditAttribution: Crell commented*sigh* Dries, we had been over this before and settled on separate line, which is all over core now in a thousand places. I'm not rolling the patch to change all of them now, especially when I don't agree with it.
Comment #18
Dries CreditAttribution: Dries commentedMy preference is
))->fetchField()
.Crell, I don't remember having settled on that. I don't feel that strong about it though, and it certainly shouldn't hold up this patch.
Comment #19
andypostReroll with ))->
Comment #20
BerdirYou can replace that with:
And that one probably with: (untested)
Comment #21
andypostFirst is chandged
Second is not working - aids holds keyed subarray with only 1 key - 'type' but if fetchassoc then we get whole record in sub array
Comment #22
BerdirLooks good now.
We agreed that we could probably simplify the array because the sub-array contains only a single key -> value pair, but we can do that in another issue.
Comment #23
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.
Comment #24
andypostSo here follow-up #476972: Optimizations of action_info array