Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#58461 closed defect (bug) (worksforme)

WP Rest API List Categories Endpoint - Uncaught DivisionByZeroError in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:351

Reported by: mcmwebsol's profile mcmwebsol Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.2.2
Component: REST API Keywords:
Focuses: Cc:

Description (last modified by peterwilsoncc)

Going to the categories list endpoint
on PHP 8.0 using WP 6.2.2 running Twenty Twenty-Two theme with no plugins gives the following error:

PHP Fatal error: Uncaught DivisionByZeroError: Division by zero in /wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php:351
Stack trace:
#0 /wp-includes/rest-api/class-wp-rest-server.php(1181): WP_REST_Terms_Controller->get_items(Object(WP_REST_Request))
#1 /wp-includes/rest-api/class-wp-rest-server.php(1028): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wp/v2/categori...', Array, NULL)
#2 /wp-includes/rest-api/class-wp-rest-server.php(442): WP_REST_Server->dispatch(Object(WP_REST_Request))
#3 /wp-includes/rest-api.php(410): WP_REST_Server->serve_request('/wp/v2/categori...')
#4 /wp-includes/class-wp-hook.php(308): rest_api_loaded(Object(WP))
#5 /wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(, Array)
#6 /wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#7 /wp-includes/class-wp.php(399): do_action_ref_array('parse_request', Array)
#8 /wp-includes/class-wp.php(780): WP->parse_request()
#9 /wp-includes/functions.php(1334): WP->main()
#10 /wp-blog-header.php(16): wp()
#11 /index.php(17): require('/nas/content/li...')
#12 {main}
 thrown in /wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php on line 351

Attachments (1)

58461.diff (703 bytes) - added by nihar007 12 months ago.

Download all attachments as: .zip

Change History (5)

#1 @peterwilsoncc
12 months ago

  • Description modified (diff)

#2 @nihar007
12 months ago

I tried to recreate the issue in WordPress 6.2.2
1: I activated Twenty Twenty-Two theme
2: I deleted all plugins from setup

But didn't see any issue.
Although I added a diff here for $per_page variable

12 months ago

#3 @mcmwebsol
12 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

I tracked it down to an environment issue.

#4 @peterwilsoncc
12 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.