Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#50228 new defect (bug)

Plugins can inadvertently trigger `wp_die()` infinite loop during site creation

Reported by: iandunn's profile iandunn Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords:
Focuses: Cc:

Description (last modified by iandunn)

Problem

This is one example of an execution path that leads to an infinite loop, but there are probably several others. It can happen to any callback that tries to query a new site's tables after the wp_insert_site action, and before the make_db_current_silent() call inside wp_initialize_site().

  1. Creating a new site in a Multisite network will eventually call wp_initialize_site()
  2. That calls switch_to_blog()
  3. A plugin could hook into the switch_blog() action, and call get_locale().
  4. That calls get_option(), which will trigger a MySQL error, because the tables don't exist.
  5. wpdb->print_error( ) calls _default_wp_die_handler()
  6. That calls get_language_attributes(), which calls get_option()
  7. The process repeats until PHP gives up.

( ! ) Fatal error: Uncaught Error: Maximum function nesting level of '256' reached, aborting! in wp-includes/class-wp-hook.php on line 196

It's not obvious to plugin developers that this kind of thing can happen, so I think Core should handle it gracefully.

Related: #49263

Potential solutions

  1. wp_die() coule call a new _installing_wp_die_handler() when is_installing() is true. This could be a minimal version of _default_wp_die_handler(), where no database queries are made.

  2. _default_wp_die_handler() could avoid calling get_language_attributes() when is_installing() is true.

  3. Something else?

Change History (2)

#1 @iandunn
5 years ago

  • Component changed from General to Upgrade/Install
  • Focuses multisite added

#2 @iandunn
5 years ago

  • Component changed from Upgrade/Install to Networks and Sites
  • Description modified (diff)
  • Focuses multisite removed
Note: See TracTickets for help on using tickets.