Page unable to reach
-
Hello Team,
I have installed amp and activated it with Transitional mode. On browser It showing me green tick on AMP side, But when I am trying to test it on AMP testing tool it shows me error.
Please refer to the link below
https://search.google.com/test/amp?id=MNRdPW0BxNZzmC-IdqXEMw
The page I need help with: [log in to see the link]
-
PHP Fatal error: Uncaught DOMException: Not Found Error in /wp-content/plugins/amp/includes/sanitizers/class-amp-base-sanitizer.php:477\nStack trace:\n#0 /wp-content/plugins/amp/includes/sanitizers/class-amp-base-sanitizer.php(477): DOMElement->removeAttributeNode(Object(DOMAttr))\n#1 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(585): AMP_Base_Sanitizer->remove_invalid_attribute(Object(DOMElement), Object(DOMAttr), Array)\n#2 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(302): AMP_Tag_And_Attribute_Sanitizer->process_node(Object(DOMElement))\n#3 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(287): AMP_Tag_And_Attribute_Sanitizer->sanitize_element(Object(DOMElement))\n#4 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(287): in /wp-content/plugins/amp/includes/sanitizers/class-amp-base-sanitizer.php on line 477
@ashishjangra-1 Can you temporarily deactivate any page builders you have active, along with any caching plugin and other amp plugins before then switching to
transitionalmode again and checking?If that doesn’t help solve the issue please share your Site Health information.
@ashishjangra-1 The site linked to above indicates it is using “AMP for WP 0.9.98.9”. Did you turn off this AMP plugin?
In regards to the specific error in the stack trace, I’m confused why the attribute node is not present in the DOM when it is being removed in
\AMP_Base_Sanitizer::remove_invalid_attribute(). You can try to make this change to prevent the error from happeningdiff --git a/includes/sanitizers/class-amp-base-sanitizer.php b/includes/sanitizers/class-amp-base-sanitizer.php index 2482db29..3f957066 100644 --- a/includes/sanitizers/class-amp-base-sanitizer.php +++ b/includes/sanitizers/class-amp-base-sanitizer.php @@ -485,7 +485,7 @@ abstract class AMP_Base_Sanitizer { $node = $attribute; } $should_remove = $this->should_sanitize_validation_error( $validation_error, compact( 'node' ) ); - if ( $should_remove ) { + if ( $should_remove && $element === $node->parentNode ) { $element->removeAttributeNode( $node ); $this->clean_up_after_attribute_removal( $element, $node, $validation_error ); }But I’m not sure why the error is happening in the first place.
@westonruter Hi, Yes for the meantime I have to disable it. As it was giving 500 Error. I am going to setup all the stuff on development URL now and will add the hack which you shared.
Hi @westonruter I have changed the function but still same fatal error. Please refer to the code below.
public function remove_invalid_attribute( $element, $attribute, $validation_error = [] ) { if ( is_string( $attribute ) ) { $node = $element->getAttributeNode( $attribute ); } else { $node = $attribute; } $should_remove = $this->should_sanitize_validation_error( $validation_error, compact( 'node' ) ); + if ( $should_remove && $element === $node->parentNode ) { $element->removeAttributeNode( $node ); $this->clean_up_after_attribute_removal( $element, $node, $validation_error ); } return $should_remove; }Here is the error
PHP Fatal error: Uncaught DOMException: Not Found Error in /wp-content/plugins/amp/includes/sanitizers/class-amp-base-sanitizer.php:489\nStack trace:\n#0 /wp-content/plugins/amp/includes/sanitizers/class-amp-base-sanitizer.php(489): DOMElement->removeAttributeNode(Object(DOMAttr))\n#1 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(587): AMP_Base_Sanitizer->remove_invalid_attribute(Object(DOMElement), Object(DOMAttr), Array)\n#2 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(304): AMP_Tag_And_Attribute_Sanitizer->process_node(Object(DOMElement))\n#3 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(287): AMP_Tag_And_Attribute_Sanitizer->sanitize_element(Object(DOMElement))\n#4 /wp-content/plugins/amp/includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php(287): AMP_Tag_And_Attrib in /wp-content/plugins/amp/includes/sanitizers/class-amp-base-sanitizer.php on line 489@ashishjangra-1 Sorry for the delay. Would you please try this patch instead: https://gist.github.com/westonruter/e6762e351c40d2a480cbf5d63da9fa5c
And please share any output from the error log.
Also, what themes/plugins do you have active?
@ashishjangra-1 actually, it appears what you have reported may be a duplicate of what was reported here: https://wordpress.org/support/topic/php-fatal-error-uncaught-domexception-not-found-error-in/#post-12093081
I have a fix: https://github.com/ampproject/amp-wp/pull/3682
Please test.
1.4.1-RC1 now available for testing: https://github.com/ampproject/amp-wp/releases/tag/1.4.1-RC1
Hi Weston,
Thank you, It works. but one new issue I have realized that once after updates, it validation is Valid but website style has been completely broken. After debug I found that its getting on theme root’s style.css however my theme has different style which is under css directory.
I’ll be glad if you can tell me where i am doing wrong.
AMP mode is Transitional.
When I use array(‘template_dir’=>’amp’) this gives error “PHP Fatal error: Uncaught Error: Using $this when not in object context in amp/single.php”.
Looking forward to hear from you.
Thanks
It appears you are trying to use the Reader mode templates in Transitional mode. If that is the case, then at the moment you should remove the
amptheme support in your theme. Otherwise, if you want to use Transitional mode (which is better than Reader) then you should be copying your theme’ssingle.phpinto thatamp/directory. In Standard/Transitional modes, theme templates are normal WordPress templates and they do not use$thislike the Reader mode templates currently do.Nevertheless, if possible it is better to not have to override the templates at all. The point of Transitional and Standard modes is to re-use your active theme’s templates entirely. Overriding a template in Transitional mode should be very uncommon.
Hi Weston,
As i already mentioned above that Layout of the website is messed up with transitional mode. I debug it and found that stylesheet.css which is under css directory is not getting call on amp site. AMP site just picking up theme root style.css. Another thing is our website navigation are using JS/Bootstrap features which another that impacts the website layout.
Thanks
The topic ‘Page unable to reach’ is closed to new replies.