fb-instant-articles
fb-instant-articles copied to clipboard
PHP Fatal error: Cannot redeclare admin_notice__scrape_invalidation_failed()
Steps required to reproduce the problem
- Install plugin
- Setup plugin
- Select and Edit multiple post, press save.
Expected Result
Nothing. Success message.
Actual Result
PHP Fatal error: Cannot redeclare admin_notice__scrape_invalidation_failed() (previously declared in /home/vocket/thevocket.com/web/app/plugins/fb-instant-articles/facebook-instant-articles.php:525)
Version Info
Please state exact versions, not latest or new.
- Plugin version: 4.1.1
- WordPress version: 4.9.8
- PHP version: 7.2
Without the above information we are not able to debug the issue and will close it.
I also meet this error or this cause happen from version of php 7.3
PHP message: PHP Fatal error: Cannot redeclare admin_notice__scrape_invalidation_failed() (previously declared in fb-instant-articles/facebook-instant-articles.php:492) in wp-content/plugins/fb-instant-articles/facebook-instant-articles.php on line 490" while reading response header from upstream, client: 141.101.107.148, server: camboland.com, request: "POST /wp-admin/post.php?post=6396&action=edit&meta-box-loader=1&meta-box-loader-nonce=988d218e86&_locale=user HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "www.camboland.com", referrer: "post.php?post=6396&action=edit"
Same here:
2021/10/15 16:18:52 [error] 3457144#3457144: *25365571 FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot redeclare admin_notice__scrape_invalidation_failed() (previously declared in /var/www/prod/wp-content/plugins/fb-instant-articles/facebook-instant-articles.php:492) in /var/www/prod/wp-content/plugins/fb-instant-articles/facebook-instant-articles.php on line 490"
Did any of you find workarounds?
The admin_notice__scrape_invalidation_failed() function (and others) are nested inside other functions, which is a bad idea for exactly this reason. The parent function is hooked to post_updated, so if that hook runs twice (perhaps for different posts), then the inner functions are attempted to be defined twice.
For what it's worth... bulk-updating posts is all it takes to trigger this error.
if (!function_exists('admin_notice__scrape_invalidation_failed')) {}
Wrapped that function with that and the next (success) as well. Un-nesting those functions is definitely the long-term solution, but this at least keeps the plugin from breaking until the code is refactored.
Plugin version: 4.2.1 - 5 PHP version: 7.4 WP version: 6.0.1 - 6.0.3