[wp-trac] [WordPress Trac] #51817: WP-Admin - Optimize main wpquery with 'fields' => 'ids' causes notice
WordPress Trac
noreply at wordpress.org
Wed Nov 18 15:21:57 UTC 2020
#51817: WP-Admin - Optimize main wpquery with 'fields' => 'ids' causes notice
-----------------------------------------+-----------------------------
Reporter: eumene | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 5.5.3
Severity: normal | Keywords:
Focuses: administration, performance |
-----------------------------------------+-----------------------------
Hi all
I have a post_type (Woocommerce product) with a lot of data in the post
contents. So, in wp-admin, WP requires a lot of memory to list them
(sometimes I got an OUT-OF-MEMORY)
So, I tried to make a lighter query adding via hooks the query params
'fields' => 'ids'
It works! The query is more fast and WP does not require so many memory
but I got some annoying notices
In method _display_rows in WP_Posts_List_Table you have
{{{
foreach ( $posts as $a_post ) {
$post_ids[] = $a_post->ID;
}
}}}
The method supposes that $posts will be an array of WP_Post object .
In my case it is an array of integer
Can you handle this scenario?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51817>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list