compatibility with PHP 8
-
it seems the plugin is not compatible with PHP 8
When I change my php code to 7.4 the page https://lemagcinema.fr/festivals/amy-grantham-lily-deauville-2013/amp/ is ok but with 8.1 it is not …What is troubling is that the behaviour is not the same for all amp pages.
The page I need help with: [log in to see the link]
-
Hi @lemagcinema,
Thanks for report the issue, we have a set of tests with the WordPress core and core themes, could you share with us your UUID? Your will find at the AMP settings panel.
here you are: ampwp-b8018750-8cdd-5a56-86a5-e5c760289882
Hi @fellyph any news on my case ?
Hi @lemagcinema,
It looks like the error page is being generated before AMP even gets to process all the page, looks like another plugin is generating the error. However, the custom AMP rewrite rule might be what triggers that error.
The plugin “PHP Compatibility Checker” creates any report? Or do you have access to the error log?
PHP compatibility checker is not working with PHP 8
Here are the log files … The fatal error is on amp plugin
Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 133 Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 98 Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 79 Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/vendor-prod/pimple/pimple/src/Pimple/Container.php on line 143 Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 60 Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 66 Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 72 Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 76 Deprecated: Return type of iThemesSecurity\Lib\Lockout\Execute_Lock\Context::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/lockout/execute-lock/abstract-context.php on line 56 Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 578 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php on line 2170 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php on line 2170 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php on line 2170 <strong>Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /home/lemagcin/www/wp/wp-content/plugins/amp/includes/embeds/class-amp-gallery-embed-handler.php:82 Stack trace: #0 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/embeds/class-amp-gallery-embed-handler.php(40): AMP_Gallery_Embed_Handler->filter_post_gallery_markup('', '') #1 /home/lemagcin/www/wp/wp-includes/class-wp-hook.php(309): AMP_Gallery_Embed_Handler->generate_gallery_markup('', '') #2 /home/lemagcin/www/wp/wp-includes/plugin.php(189): WP_Hook->apply_filters('', Array) #3 /home/lemagcin/www/wp/wp-includes/media.php(2313): apply_filters('post_gallery', '', '', 1) #4 /home/lemagcin/www/wp/wp-includes/shortcodes.php(356): gallery_shortcode('', '', 'gallery') #5 [internal function]: do_shortcode_tag(Array) #6 /home/lemagcin/www/wp/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(galler...', 'do_shortcode_ta...', '[gallery]\n<p>Am...') #7 /home/lemagcin/www/wp/wp-includes/class-wp-hook.php(307): do_shortcode('[gallery]\n<p>Am...') #8 /home/lemagcin/www/wp/wp-includes/plugin.php(189): WP_Hook->apply_filters('[gallery]\n<p>Am...', Array) #9 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(366): apply_filters('the_content', '[gallery]\r\n<p>A...') #10 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(147): AMP_Post_Template->build_post_content() #11 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(192): AMP_Post_Template->set_data() #12 /home/lemagcin/www/wp/wp-content/plugins/amp/templates/html-start.php(22): AMP_Post_Template->get('html_tag_attrib...') #13 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(485): include('/home/lemagcin/...') #14 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(238): AMP_Post_Template->verify_and_include('/home/lemagcin/...', 'html-start') #15 /home/lemagcin/www/wp/wp-content/plugins/amp/templates/single.php(21): AMP_Post_Template->load_parts(Array) #16 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(485): include('/home/lemagcin/...') #17 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(238): AMP_Post_Template->verify_and_include('/home/lemagcin/...', 'single') #18 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(227): AMP_Post_Template->load_parts(Array) #19 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/reader-template-loader.php(36): AMP_Post_Template->load() #20 /home/lemagcin/www/wp/wp-includes/template-loader.php(106): include('/home/lemagcin/...') #21 /home/lemagcin/www/wp/wp-blog-header.php(19): require_once('/home/lemagcin/...') #22 /home/lemagcin/www/index.php(17): require('/home/lemagcin/...') #23 {main} thrown in /home/lemagcin/www/wp/wp-content/plugins/amp/includes/embeds/class-amp-gallery-embed-handler.php on line 82</strong> Deprecated: preg_grep(): Passing null to parameter #3 ($flags) of type int is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wpsso/lib/com/util.php on line 1807 Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/lemagcin/www/wp/wp-includes/rewrite.php on line 500 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php on line 2170 Warning: Cannot modify header information - headers already sent by (output started at /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php:545) in /home/lemagcin/www/wp/wp-content/plugins/cookie-notice/includes/frontend.php on line 68 Warning: Cannot modify header information - headers already sent by (output started at /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php:545) in /home/lemagcin/www/wp/wp-content/plugins/cookie-notice/includes/frontend.php on line 69 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php on line 2170 Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wp-asset-clean-up/classes/Misc.php on line 369 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/includes/admin/feedzy-rss-feeds-import.php on line 2170 Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wp-asset-clean-up/classes/Misc.php on line 369 Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 585 Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 606 Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 613 Deprecated: Return type of ITSEC_Lib_Distributed_Storage_Cursor::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/lemagcin/www/wp/wp-content/plugins/better-wp-security/core/lib/class-itsec-lib-distributed-storage.php on line 620 Deprecated: version_compare(): Passing null to parameter #2 ($version2) of type string is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/load.php on line 31 Deprecated: version_compare(): Passing null to parameter #2 ($version2) of type string is deprecated in /home/lemagcin/www/wp/wp-content/plugins/feedzy-rss-feeds/vendor/codeinwp/themeisle-sdk/load.php on line 36 Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lemagcin/www/wp/wp-content/plugins/polylang/include/class-polylang.php on line 98 Deprecated: Automatic conversion of false to array is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wp-rocket/inc/3rd-party/plugins/seo/yoast-seo.php on line 10 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wp-smushit/core/modules/helpers/class-parser.php on line 229 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wp-smushit/core/modules/helpers/class-parser.php on line 234 Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wp-rocket/inc/vendors/ip_in_range.php on line 136 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wordpress-seo/src/conditionals/third-party/elementor-edit-conditional.php on line 22 Deprecated: Constant FILTER_SANITIZE_STRING is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wordpress-seo/src/conditionals/third-party/elementor-edit-conditional.php on line 28 Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in /home/lemagcin/www/wp/wp-content/plugins/wp-asset-clean-up/classes/Misc.php on line 369
Hi @lemagcinema,
Thanks, for sharing the error.log it was really helpful, I will try to reproduce the error and open a GitHub issue.
In particular, this this the relevant error:
Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /home/lemagcin/www/wp/wp-content/plugins/amp/includes/embeds/class-amp-gallery-embed-handler.php:82 Stack trace: #0 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/embeds/class-amp-gallery-embed-handler.php(40): AMP_Gallery_Embed_Handler->filter_post_gallery_markup('', '') #1 /home/lemagcin/www/wp/wp-includes/class-wp-hook.php(309): AMP_Gallery_Embed_Handler->generate_gallery_markup('', '') #2 /home/lemagcin/www/wp/wp-includes/plugin.php(189): WP_Hook->apply_filters('', Array) #3 /home/lemagcin/www/wp/wp-includes/media.php(2313): apply_filters('post_gallery', '', '', 1) #4 /home/lemagcin/www/wp/wp-includes/shortcodes.php(356): gallery_shortcode('', '', 'gallery') #5 [internal function]: do_shortcode_tag(Array) #6 /home/lemagcin/www/wp/wp-includes/shortcodes.php(228): preg_replace_callback('/\\[(\\[?)(galler...', 'do_shortcode_ta...', '[gallery]<p>Am...') #7 /home/lemagcin/www/wp/wp-includes/class-wp-hook.php(307): do_shortcode('[gallery]<p>Am...') #8 /home/lemagcin/www/wp/wp-includes/plugin.php(189): WP_Hook->apply_filters('[gallery]<p>Am...', Array) #9 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(366): apply_filters('the_content', '[gallery]\r<p>A...') #10 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(147): AMP_Post_Template->build_post_content() #11 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(192): AMP_Post_Template->set_data() #12 /home/lemagcin/www/wp/wp-content/plugins/amp/templates/html-start.php(22): AMP_Post_Template->get('html_tag_attrib...') #13 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(485): include('/home/lemagcin/...') #14 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(238): AMP_Post_Template->verify_and_include('/home/lemagcin/...', 'html-start') #15 /home/lemagcin/www/wp/wp-content/plugins/amp/templates/single.php(21): AMP_Post_Template->load_parts(Array) #16 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(485): include('/home/lemagcin/...') #17 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(238): AMP_Post_Template->verify_and_include('/home/lemagcin/...', 'single') #18 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/class-amp-post-template.php(227): AMP_Post_Template->load_parts(Array) #19 /home/lemagcin/www/wp/wp-content/plugins/amp/includes/templates/reader-template-loader.php(36): AMP_Post_Template->load() #20 /home/lemagcin/www/wp/wp-includes/template-loader.php(106): include('/home/lemagcin/...') #21 /home/lemagcin/www/wp/wp-blog-header.php(19): require_once('/home/lemagcin/...') #22 /home/lemagcin/www/index.php(17): require('/home/lemagcin/...') #23 {main} thrown in /home/lemagcin/www/wp/wp-content/plugins/amp/includes/embeds/class-amp-gallery-embed-handler.php on line 82
OK, I can reproduce the issue by adding a gallery shortcode that is just
[gallery]
without any shortcode attributes. When that is done,$attrs
is just an empty string instead of an array.So it seems like this is the quick fix:
--- a/includes/embeds/class-amp-gallery-embed-handler.php +++ b/includes/embeds/class-amp-gallery-embed-handler.php @@ -51,6 +51,10 @@ public function generate_gallery_markup( $html, $attrs ) { * @return string Markup for the gallery. */ protected function filter_post_gallery_markup( $html, $attrs ) { + if ( ! is_array( $attrs ) ) { + $attrs = []; + } + // Use <amp-carousel> for the gallery if requested via amp-carousel shortcode attribute, or use by default if in legacy Reader mode. // In AMP_Gallery_Block_Sanitizer, this is referred to as carousel_required. $is_carousel = isset( $attrs['amp-carousel'] )
@lemagcinema But maybe the
gallery
shortcode is accidentally missing its attributes?Actually, I forgot. When a
[gallery]
shortcode lacks any attributes, then what happens is is it uses the images attached to the current post (or which are not attached to any post).I do not think the gallery is accidentally missing its args as https://lemagcinema.fr/festivals/amy-grantham-lily-deauville-2013/ is working properly …
So I think your fix will be helpful as soon as available.A quick fix would be to edit the
post_content
to add a default shortcode attribute. So replace:[gallery]
with[gallery id=0]
. This would eliminate the fatal error. Plugin code to do the same would be:add_filter( 'the_content', static function ( $content ) { return str_replace( '[gallery]', '[gallery id=0]', $content ); } );
I’ve opened a pull request to fix this in the next version of the plugin: https://github.com/ampproject/amp-wp/pull/6939
So once 2.2.2 is out, you can remove any such workarounds.
-
This reply was modified 3 years, 1 month ago by
Weston Ruter.
Hello @lemagcinema
We just released AMP plugin version 2.2.2 which fixes the error you encountered, please update AMP plugin and let us know if that resolves your issue.
@lemagcinema
As we didn’t receive a response I’ll mark this as resolved. Feel free to open a new support topic if you require any further assistance. -
This reply was modified 3 years, 1 month ago by
- The topic ‘compatibility with PHP 8’ is closed to new replies.