I'm not exactly sure why this is happening, but we've been getting php errors that look like this:
Error: Call to a member function getElementsByTagName() on null in /htdocs/modules/filter/filter.module, line 1123
Basically if you create a standard, empty DOMDocument object in PHP and then try to pass that to filter_dom_serialize() it will cause a white screen as it stands now.
$document = new DOMDocument();
$result = filter_dom_serialize($document);
this will cause drupal to throw the following error, usually on a white screen:
Error: Call to a member function getElementsByTagName() on null in /htdocs/modules/filter/filter.module, line 1123
Comments
Comment #1
leolandotan commentedI created a patch from the mentioned link on the main issue description.
Comment #2
elusivemind commentedGood work on adding in this defensive programming. It has corrected an issue that reared its ugly head on an update to PHP 5.5.24 and then 5.5.25. Oddly, when you go to 5.5.26, it seems to work fine again - but still the patch you have submitted is a great addition and should be rolled ASAP into Drupal Core. That is my opinion after my review and implementation of your code on many sites including sites for
The Doors
Styx
Imagine Dragons
R5
and about 35 similar ones that were fixed with this patch.
Well done.
Comment #3
elusivemind commentedComment #4
cilefen commentedPlease check if this is an issue with Drupal 8. If so, it must be fixed there first according to the backport policy.
Comment #5
elusivemind commentedConfirmed the bug exists in D8. Patch attached
Comment #6
elusivemind commentedComment #8
cilefen commentedRe #6, you cannot review your own patches.
Comment #10
cilefen commentedI am not sure these comments are necessary. The meaning of the code is clear to me.
Comment #11
elusivemind commentedComments concern addressed.
Comment #12
leolandotan commentedThanks @ElusiveMind! :)
Comment #13
cilefen commented@leolando.tan Would you like to offer a review?
Comment #14
leolandotan commentedI have tested the patch by:
Since the Filter module's description is "Filters content in preparation for display.". The test contents I saved were blank, with HTML and "unclosed" HTML using basic, restricted and full mode and also in quick edit mode. So far checked the Status report and Recent log messages after accessing pages and adding dummy content, they appear clean with no errors.
There are no additions to the UI since this is a logical process fix.
@cilefen Sorry for responding quite late. I hope this review is alright.
Comment #15
catchThis needs test coverage.
Also if it really is only due to a regression in 5.5.25 we should document that.
Comment #16
jeroentCreated a test.
Patch error_call_to_a_member-2511306-16-test-only.patch should fail.
Comment #17
elusivemind commentederror_call_to_a_member-2511306-16-test-only.patch
Is a patch to Drupal 7. The original was an issue with Drupal 7, so I checked Drupal 8 for the same issue and patched it there.
Comment #18
cilefen commentedRe #14 @leolando.tan That is great - it is actually much better than we usually get!
Comment #19
elusivemind commentedRe: #16 @JeroenT - I am wondering if this is because the test is running on something > PHP 5.5.25. I will do some work on this using the 5.5.25 environment and 5.5.24 and see if it does, indeed, fail there. As stated in #15, this really is an issue only with these two versions of PHP, but because Acquia just upgraded everyone to PHP 5.5.25, we are having this problem and we should have a defensively programmed solution. I will work on this today or tomorrow.
Thanks for the input. Will keep working.
Comment #20
elusivemind commentedIf passing only an instance of DOMDocument to Html::serialize, you will reproduce this error in Drupal 8. I have attached at test patch in an attempt to reproduce this error.
Comment #21
elusivemind commentedI can only assume this passed because it is running a version of PHP that is not 5.5.24 or 5.5.25. I have attached the errors I am getting using the same code.
** edit ** - it marked it as succeeding at first
Comment #23
elusivemind commentedAny chance I can get some traction on this since I produce a test that caused the problem?
Comment #24
elusivemind commentedComment #25
cilefen commentedWe can't have commented-out code committed.
We need a combined patch (#16 + #10) in addition to a test-only patch.
Comment #26
elusivemind commentedCreated a patch to address changes in #16 + 10. Also created a test only patch.
Comment #29
elusivemind commentedAddressing testing issues. Test seems to fail if not included with main patch.
Comment #30
elusivemind commentedComment #31
cilefen commentedThat is a good thing.
Comment #32
elusivemind commentedAye. Many apologies for the learning curve.
Comment #33
elusivemind commentedThe patch for Drupal 8 has passed. What is the next step in getting this patch implemented for Drupal 8 as well as 7. I appreciate your patience and help.
Comment #34
elusivemind commentedComment #35
catchTrailing whitespace is fixable on commit.
We should use !== for the $body_node != NULL comparison.
this could probably use some docs to explain what it's testing.
Comment #36
elusivemind commentedAdded comments and removed trailing white spaces.
Comment #37
elusivemind commentedComment #38
elusivemind commentedAdded type comparison (!==)
Comment #39
elusivemind commentedComment #40
catchCommitted/pushed to 8.0.x, thanks!
Comment #42
elusivemind commentedWhat about the version 7 patch?
Comment #43
cilefen commentedI moved it to D7 for the backport.
Comment #44
elusivemind commentedComment #45
elusivemind commentedComment #47
elusivemind commentedAdded description to test
Comment #48
elusivemind commentedComment #50
elusivemind commentedComment #51
elusivemind commentedReady for merge?
Comment #52
cilefen commented@ElusiveMind That's a +1 from you, but it's peer review to become RTBC.
Comment #53
cilefen commentedCan you post the steps to reproduce in the issue summary? I'll try to get someone to review it in core mentoring.
Comment #54
elusivemind commentedComment #55
charginghawk commentedI have tested the patch by:
- Cloning down D7
- Installing a fresh Drupal site
- Testing that it's broken
- Applying patch
- Testing it again
- No error!
I'd say RTBC.
Comment #56
David_Rothstein commentedCommitted to 7.x - thanks!
Fixed on commit: