WordPress.org

Making WordPress.org

#3894 closed defect (fixed)

Avoid expensive database queries from redirect_canonical on 404's

Reported by: dd32 Owned by: dd32
Milestone: Priority: normal
Component: Support Forums Keywords:
Cc:

Description

There's some URLs on the Support Forum which are triggering OOM fatal errors when requested, such as the following:

https://wordpress.org/support/topic/test/*1*

This is caused as it doesn't match an existing topic, and it causes WordPress to perform a query like this, which has thousands of results in the forums:

SELECT ID FROM wp_posts
WHERE post_name LIKE '1%' AND post_type IN ('post', 'page', 'attachment', 'forum', 'topic', 'reply', 'helphub_article', 'helphub_version') AND post_status = 'publish'

The following commit avoids these by requiring that the name query var is at least 5 characters long, which appears to be long enough to reduce the number of DB rows to avoid fatal errors while also allowing for redirects when a partial post_name is provided.

Change History (1)

#1 @dd32
13 months ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In 7806:

Support Forums: Disable canonical on 404 requests when a short name query var is provided.

This is to avoid some expensive database queries which causes out-of-memory fatal errors on the Support Forum.

Fixes #3894.

Note: See TracTickets for help on using tickets.