Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#55425 closed enhancement (fixed)

Customize: Fetch presence of published pages more optimally (refactor)

Reported by: nagpai's profile nagpai Owned by: nagpai's profile nagpai
Milestone: 6.0 Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: has-patch needs-testing
Focuses: performance Cc:

Description

The function has_published_pages on line 5753 seems to fetch all the data of pages, whereas what is needed is only whether published pages exist or not.

While this may not matter much in sites that have fewer pages, on website that has too many pages, it may create an out of memory error. I will test and submit a patch to fetch only the count of published pages that will help improve efficiency.

Attachments (1)

55425.0.diff (742 bytes) - added by nagpai 2 years ago.
Fix for ticket #55425

Download all attachments as: .zip

Change History (9)

#1 @dlh
2 years ago

  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 5.9.2 to 4.7

Welcome back to Trac, @nagpai! Thanks for the report.

The current logic was added for #38013, where 'number' => 1 was mentioned specifically in the description but not the final patch, so it seems like it was an oversight.

Care to submit a patch or a Pull Request? Once we have a patch, I think this ticket can be added to the 6.0 milestone.

#2 @nagpai
2 years ago

Hey @dlh , Thank you so much for reviewing this ticket and adding the very useful context! I was traveling last week, and will submit a patch in the next couple of days. Thanks :D

@nagpai
2 years ago

Fix for ticket #55425

#3 @nagpai
2 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

I just uploaded a patch. I confirm having tested this on a test site with a few pages published, and none published. It seems to work fine. Would be great if someone can test it too.

This is my first patch submission to WordPress and I hope to do more :) . I have tried to follow the instructions in the contributors' handbook. Advance apologies for any mistakes. Thanks for your kind guidance @dlh !

Also props to my colleague and guide @tyxla who guided me with the next steps too.

#4 @peterwilsoncc
2 years ago

  • Focuses performance added

#6 @peterwilsoncc
2 years ago

  • Milestone changed from Future Release to 6.0

I've moved this on the the 6.0 milestone as it appears to be a quick performance win.

To make sure the unit tests still pass, I've set up a linked pull request.

@nagpai I made some minor white space changes to your patch to observe the WordPress PHP coding standards.

#7 @peterwilsoncc
2 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 53057:

Customizer: Improve performance checking for published pages.

Improve the performance of WP_Customize_Manager::has_published_pages() by limiting the database query to a single published page, down from querying all published pages.

Props nagpai, dlh, tyxla.
Fixes #55425.

Note: See TracTickets for help on using tickets.