Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51629 closed defect (bug) (duplicate)

[php8] TypeError: call_user_func_array(): non-static method WP_Feed_Cache::create() cannot be called statically

Reported by: bph's profile bph Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.6
Component: Feeds Keywords: php8 has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be a valid callback, non-static method WP_Feed_Cache::create() cannot be called statically in /home/customer/www/icodeforapurpose.com/public_html/wp-includes/SimplePie/Registry.php:214

**StackTrace**

#0 /wp-includes/class-simplepie.php(1412): SimplePie_Registry->call('Cache', 'get_handler', Array) 
#1 /wp-includes/feed.php(821): SimplePie->init() 
#2 /wp-includes/widgets.php(1513): fetch_feed('https://wordpre...') 
#3 /wp-content/plugins/wordpress-beta-tester/src/WPBT/WP_Beta_Tester.php(288): wp_widget_rss_output('https://wordpre...', Array) 
#4 /wp-content/plugins/wordpress-beta-tester/src/WPBT/WP_Beta_Tester.php(256): WP_Beta_Tester->parse_development_feed('5.6') 
#5 /wp-admin/includes/template.php(1389): WP_Beta_Tester->beta_tester_dashboard('', Array) 
#6 /wp-admin/includes/dashboard.php(256): do_meta_boxes(Object(WP_Screen), 'normal', '') 
#7 /wp-admin/index.php(177): wp_dashboard() 
#8 {main} thrown in /wp-includes/SimplePie/Registry.php on line 214

Attachments (1)

51629.patch (541 bytes) - added by ayeshrajans 4 years ago.

Download all attachments as: .zip

Change History (15)

#2 @SergeyBiryukov
4 years ago

  • Component changed from General to Feeds
  • Description modified (diff)
  • Keywords php8 added
  • Milestone changed from Awaiting Review to 5.6
  • Summary changed from [php8] TypeError: call_user_func_array() to [php8] TypeError: call_user_func_array(): non-static method WP_Feed_Cache::create() cannot be called statically

#3 @ayeshrajans
4 years ago

In PHP 8.0 attempting to call a non-static as static causes fatal error in PHP 8.0. This was silenced with the @ operator which suppressed the PHP warning, but now that it's a type error, it bubbles up to the error handler.

From what I see, Cache::create method is moved to SimplePie_Cache::get_handle. I don't see why we can't rewrite the class to SimplePie_Cache. I will attach a patch, could you give it a try please? I suppose the fix should be sent to upstream SimplePie project before we make changes in core, or wait for a fix from the maintainers upstream.

@ayeshrajans
4 years ago

#4 @afragen
4 years ago

@ayeshrajans perhaps I'm incorrect but as SimplePie is an includes library and not native to WordPress I think the solution needs to be outside of the SimplePie framework.

#5 @ayeshrajans
4 years ago

@afragen - I think so too, I will try to submit a PR to upstream Simplepie. We already have an updated Simplepie version for WordPress 5.6, so a minor update would be nice if we could squeeze one in.

#7 @bph
4 years ago

I can confirm that @afragen's patch fixes this error.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


4 years ago

#9 @hellofromTonya
4 years ago

  • Keywords commit added; needs-testing removed

This ticket was mentioned in Slack in #core by jrf. View the logs.


4 years ago

This ticket was mentioned in Slack in #core by jrf. View the logs.


4 years ago

This ticket was mentioned in Slack in #core by sergey. View the logs.


4 years ago

This ticket was mentioned in Slack in #core by jrf. View the logs.


4 years ago

#14 @SergeyBiryukov
4 years ago

  • Keywords commit removed
  • Milestone 5.6 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac! Thanks for the report.

This is more prominent with PHP 8, but is essentially the same issue as in #29204, let's continue there.

See comment:55:ticket:29204 for a detailed analysis.

Last edited 4 years ago by SergeyBiryukov (previous) (diff)
Note: See TracTickets for help on using tickets.