Ticket #5717 (reopened defect)

Opened 6 months ago

Last modified 5 months ago

404 handling optimization

Reported by: misterbisson Assigned to: ryan
Priority: normal Milestone: 2.9
Component: Optimization Version: 2.3.2
Severity: normal Keywords: 404, optimization, query_posts
Cc: rubys

Description

With permalinks enabled, requests for non-existing URL paths result in a resource intensive select. The problem is that WP::query_posts() doesn't halt execution when WP::parse_request() 404s, causing WP_Query::get_posts() to fetch the x most recent posts. More details: http://maisonbisson.com/blog/post/12035 .

The attached patch simply short-circuits WP::query_posts() if there's a 404. At rboren's suggestion, it also calls WP_Query::parse_query(), as some templates expect it to have run.

Honestly not sure if did_permalink is necessary, but the code works in my environments.

Attachments

404fix.diff (469 bytes) - added by misterbisson on 01/24/08 19:16:54.

Change History

01/24/08 19:16:54 changed by misterbisson

  • attachment 404fix.diff added.

(follow-up: ↓ 2 ) 01/24/08 19:19:39 changed by misterbisson

Please ignore or delete the first attached file, 404fix.diff.txt I'm an idiot.

(in reply to: ↑ 1 ) 01/24/08 19:22:21 changed by lloydbudd

Replying to misterbisson:

Please ignore or delete the first attached file, 404fix.diff.txt I'm an idiot.

Deleted. I assure you, you are not an idiot! I have met many people acting idiotic.

01/24/08 22:34:33 changed by Bobcat

Will this help with ticket #5490 ?

01/24/08 23:33:23 changed by ryan

  • owner changed from anonymous to ryan.

02/20/08 16:52:40 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6940]) Skip main posts query if 404. Props misterbisson. fixes #5717

02/21/08 05:13:18 changed by darkdragon

  • milestone changed from 2.6 to 2.5.

02/21/08 19:31:40 changed by rubys

  • status changed from closed to reopened.
  • resolution deleted.

I haven't invested why just yet, but this change totally and completely breaks AtomPub?. I wouldn't be surprised if it broke XML-RPC too. Details:

http://intertwingly.net/projects/wordpress-atompub/report.html http://intertwingly.net/projects/wordpress-atompub/apptestsuite.out

02/21/08 20:21:46 changed by rubys

  • cc set to rubys.

02/21/08 20:47:15 changed by ryan

(In [6956]) Revert [6940]. Breaks atompub. see #5717

02/21/08 20:48:25 changed by ryan

Reverted for now. I'll probably push this to 2.6 since it seems ripe for unintended consequences.

02/26/08 04:48:08 changed by ryan

  • milestone changed from 2.5 to 2.6.