Title: Uncaught TypeError after php8
Last modified: March 6, 2022

---

# Uncaught TypeError after php8

 *  Resolved [xxxLesy](https://wordpress.org/support/users/xxxlesy/)
 * (@xxxlesy)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/)
 * I’m getting various white screens after upgarding to php 8.0.16 most notably 
   on site health page and amp settings.
 * Here’s the amp settings error:
    /wp-admin/admin.php?page=amp-options /wp-admin/
   site-health.php (identical error on both) WordPress 5.9.1 Theme: Newspaper (11.4.1)
   Current plugin: AMP (2.2.1) PHP 8.0.16
 *     ```
       Error type E_ERROR was caused in line 548 of the file /var/www/vhosts/[siteurl]/httpdocs/wp-content/plugins/amp/src/Admin/SiteHealth.php. Error message: Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, array given in /var/www/vhosts/.../httpdocs/wp-content/plugins/amp/src/Admin/SiteHealth.php:548
       Stack trace:
       #0 /var/www/vhosts/.../httpdocs/wp-content/plugins/amp/src/Admin/SiteHealth.php(548): preg_match()
       #1 /var/www/vhosts/.../httpdocs/wp-content/plugins/amp/src/Admin/SiteHealth.php(634): AmpProject\AmpWP\Admin\SiteHealth::AmpProject\AmpWP\Admin\{closure}()
       #2 /var/www/vhosts/.../httpdocs/wp-content/plugins/amp/src/Admin/SiteHealth.php(491): AmpProject\AmpWP\Admin\SiteHealth->check_for_page_caching()
       #3 /var/www/vhosts/.../httpdocs/wp-content/plugins/amp/src/Admin/OptionsMenu.php(230): AmpProject\AmpWP\Admin\SiteHealth->get_page_cache_detail()
       #4 /var/www/vhosts/.../httpdocs/wp-includes/class-wp-hook.php(307): AmpProject\AmpWP\Admin\OptionsMenu->enqueue_assets()
       #5 /var/www/vhosts/.../httpdocs/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
       #6 /var/www/vhosts/.../httpdocs/wp-includes/plugin.php(474): WP_Hook->do_action()
       #7 /var/www/vhosts/.../httpdocs/wp-admin/admin-header.php(118): do_action()
       #8 /var/www/vhosts/.../httpdocs/wp-admin/admin.php(239): require_once('...')
       #9 {main}
         thrown
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Fellyph Cintra](https://wordpress.org/support/users/fellyph/)
 * (@fellyph)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/#post-15432571)
 * Hi [@xxxlesy](https://wordpress.org/support/users/xxxlesy/),
 * Thanks for contacting us, we have a [fix related](https://github.com/ampproject/amp-wp/issues/6937)
   to this issue for version 2.2.2.
 *  Thread Starter [xxxLesy](https://wordpress.org/support/users/xxxlesy/)
 * (@xxxlesy)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/#post-15432630)
 * Awesome. Thank you!
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/#post-15435608)
 * You can use the fix now by installing the [pre-release 2.2.x production build](https://github.com/ampproject/amp-wp/wiki/Development-Builds#:~:text=dev/amp.zip-,2.2.x%20Production,-%3A%20https%3A//storage.googleapis).
 *  Thread Starter [xxxLesy](https://wordpress.org/support/users/xxxlesy/)
 * (@xxxlesy)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/#post-15436469)
 * Works now. Thank you!
 *  Thread Starter [xxxLesy](https://wordpress.org/support/users/xxxlesy/)
 * (@xxxlesy)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/#post-15436476)
 * Nope, error on actual articles now. None of the amp posts work.
 * >  Failed to prepare AMP page
   >     ```
   >     A PHP error occurred while trying to prepare the AMP response. This may not be caused by the AMP plugin but by some other active plugin or the current theme. You will need to review the error details to determine the source of the error.
   > 
   >     If you get stuck, you may want to share any details in a new topic on the plugin's support forum.
   > 
   >     The exact details of the error are hidden for security reasons. To learn more about this error, enable the WordPress debugging display (by setting both WP_DEBUG and WP_DEBUG_DISPLAY to true), or look into the PHP error log. Learn more about Debugging in WordPress.
   >     ```
   > 
 * >     ```
   >     Couldn't fetch AmpProject\Dom\Element (0) [Error]
   >     /var/www/vhosts/student.si/httpdocs/wp-content/plugins/amp/vendor/ampproject/amp-toolbox/src/Optimizer/Transformer/OptimizeHeroImages.php:474
   > 
   >     #0 /var/www/vhosts/student.si/httpdocs/wp-content/plugins/amp/vendor/ampproject/amp-toolbox/src/Optimizer/Transformer/OptimizeHeroImages.php(474): DOMElement->getAttribute()
   >     #1 /var/www/vhosts/student.si/httpdocs/wp-content/plugins/amp/vendor/ampproject/amp-toolbox/src/Optimizer/Transformer/OptimizeHeroImages.php(183): AmpProject\Optimizer\Transformer\OptimizeHeroImages->removeLazyLoading()
   >     #2 /var/www/vhosts/student.si/httpdocs/wp-content/plugins/amp/vendor/ampproject/amp-toolbox/src/Optimizer/TransformationEngine.php(78): AmpProject\Optimizer\Transformer\OptimizeHeroImages->transform()
   >     #3 /var/www/vhosts/student.si/httpdocs/wp-content/plugins/amp/src/Optimizer/OptimizerService.php(46): AmpProject\Optimizer\TransformationEngine->optimizeDom()
   >     #4 /var/www/vhosts/student.si/httpdocs/wp-content/plugins/amp/includes/class-amp-theme-support.php(2131): AmpProject\AmpWP\Optimizer\OptimizerService->optimizeDom()
   >     #5 /var/www/vhosts/student.si/httpdocs/wp-content/plugins/amp/includes/class-amp-theme-support.php(1750): AMP_Theme_Support::prepare_response()
   >     #6 [internal function]: AMP_Theme_Support::finish_output_buffering()
   >     #7 /var/www/vhosts/student.si/httpdocs/wp-includes/functions.php(5212): ob_end_flush()
   >     #8 /var/www/vhosts/student.si/httpdocs/wp-includes/class-wp-hook.php(307): wp_ob_end_flush_all()
   >     #9 /var/www/vhosts/student.si/httpdocs/wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters()
   >     #10 /var/www/vhosts/student.si/httpdocs/wp-includes/plugin.php(474): WP_Hook->do_action()
   >     #11 /var/www/vhosts/student.si/httpdocs/wp-includes/load.php(1100): do_action()
   >     #12 [internal function]: shutdown_action_hook()
   >     #13 {main}
   >     ```
   > 
    -  This reply was modified 4 years, 3 months ago by [xxxLesy](https://wordpress.org/support/users/xxxlesy/).
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/#post-15439231)
 * That’s a strange one: `Couldn't fetch AmpProject\Dom\Element`. I’ve never seen
   that before.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Uncaught TypeError after php8’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/uncaught-typeerror-after-php8/#post-15439231)
 * Status: resolved