Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
filter.module
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2009 at 06:55 UTC
Updated:
23 Feb 2010 at 21:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
fgmIs it just a theming artifact, or did I just submit an empty patch and see it pass ? I don't see the patch in my previous post, and clicking on it in the "Detailed results" screen returns as WSOD.
Comment #2
fgmResubmitting just to be sure
Comment #3
jhodgdonTest bot liked it. I like it too. Definitely you need to pass a real array variable into array_shift in PHP.
Comment #4
fgmAnother take, probably a tiny bit more efficient.
I also moved the
global $userwithin the test, since it is not necessary outside it.Comment #5
jhodgdonI personally prefer to see globals declared at the top of functions - do we have a coding standard on that? ... I guess not, but it seems that most are usually declared at the top of functions, whether needed for the entire function or not. That's where I would look for them, but then again that could be an old habit left over from my years programming in ancient languages that required (or at least recommended) such things at that time. (It makes me uncomfortable to think that a given variable name could be local in one place in a function and global elsewhere, too!)
I also thought the use of the reset function is a bit odd... I had to look it up on php.net to see what it was, but I do see that it's used elsewhere in the Drupal source, so I guess I cannot really complain about it.
Anyway, I preferred your earlier patch to the current one, but if someone else wants to RTBC the second one, I wouldn't stand in the way.
Comment #6
fgmI prefer globals at the top too, but as you noticed there is no coding standard (yet ?) regarding this, and PHP allows such declarations anywhere, and placing it in the "if" means one instruction less, which is mostly insignificant but likely to be some extremely (really extremely) minor improvement. So it's really a matter of choice.
OTOH, I think that the use of reset is a better choice than the original: the first version allocates an array and copies to it before fetching a value, while the second directly uses the original array from the function return.
Comment #7
jhodgdonI hear what you are saying about efficiency, but am not necessarily convinced.
Anyway, like I said, I preferred the first patch as I could read it at first glance, and the 2nd one made me think too much. So I wouldn't personally RTBC it, but wouldn't stand in the way if someone else likes it.
Comment #8
David_Rothstein commentedHm, I could swear patch #2 was the way this function used to work, but I guess it got "fixed" at some point :)
I don't have a strong preference between reset() and array_shift(), although I agree that array_shift() is probably more readable. However, this is "needs work" because the patch in #4 doesn't actually remove the E_STRICT error.... for reset() also, you need to declare a separate array beforehand.
I also don't think it's worth moving around "global $user" (especially in a one-off manner for this function alone), so overall I prefer patch #2 as well.
Individual E_STRICT errors aren't that big of deal by themselves, but worth fixing.... However, note that there is a more comprehensive effort at #348448: Always report E_STRICT errors which would fix them all at once (and actually already includes the change from patch #2) - the advantage of fixing them all is that the testbot could then prevent new ones from ever being introduced. So this is almost a duplicate of that issue, but I guess not quite.
Comment #9
sunLet's re-attach #2 + RTBC, please.
Comment #10
jhodgdonHere is a re-attach of fgm's patch from #2. Please don't give me credit for this patch. I had marked this patch RTBC before, and Sun likes it too, so RTBC, assuming the test bot is running and is still OK with it.
Comment #11
dries commentedThis patch no longer applies for me.
Comment #12
jhodgdonApparently, someone committed essentially the patch in #4 at some time in the past. The problem reported here no longer exists.