in clipper module I ran against a breally odd issue. When enabled, about half the other modules' nodeapi hooks would not get called.
flevour hopped on for a wild bughunt, and came with this solution:
instead of doing a foreach (module_implements('nodeapi') as $name) { we call the module_implements('nodeapi') before.
Here is how to reproduce:
Just add a random node_load(1) to any nodeapi insert, update or validate, in a random module (well, not upload, because that is the last one ran, most prolly :) ).
You wil then notice that half of the data in your node/add or /edit screens are no longer saved, nor checked.
This tiny patch fixes the issue. I have no clue why, but it does fix it. :)
Comments
Comment #1
chx commentedThis is sheer impossible. I'll investigate more but there is no way module_implements' internal cache (a static variable) gets overridden, after that cache is build it's only returned. There is no reset facility as there is no need.
Comment #2
chx commentedI am babbling because of the shock.
foreach operates on a copy. it does not matter whether module_implements is immutable. Ber, what PHP version do you run?
Comment #3
Bèr Kessels commentedI find it funny that you say it is impossible, while the preactice proves that this fixes the issue.
"One should really learn to beleive reality, even if theory doesnt allow that reality"
anyhow, a slighly modded patch, one that adds a comment.
Comment #4
chx commentedAs said, I am babbling.
Second, while the patch is patch good, I told you, I fear about what else is broken. Not what your patch brokes, but there is an unknown cause and that cause might have broken other stuff too.
Comment #5
chx commentedI chatted with Goba and we worked around the problem at its root.
Comment #6
chx commentedMuch better comments. This is super-duper hard.
Comment #7
gábor hojtsyThis fixes the issue much more generally, and should be committed. (The issue is that arrays in arrays are stored with references).
+1
Comment #8
chx commentedLinking relevant Zend docs.
Comment #9
dries commentedI'm not sure I understand the PHP comment. What do you mean with 'the array pointer will be off'? Can you try to clarify that part of the code comment? Thanks.
Comment #10
Bèr Kessels commented@dries. I have no clue, really :p This array-memoy-space-pointer-stuff is way over my head. CHX, mind sharing your knowledge here?
Oh, and chx, do you mind changing this to 'normal' instead of critical? so far, in about two years, i'm the only one who ever encountered it, and that even for a rather unpopular module.
Comment #11
dries commentedI fixed up the wording/explanation a bit and committed this patch. Thanks.
Comment #12
(not verified) commented