Make WordPress Core

Changes between Version 6 and Version 7 of Ticket #56992, comment 42


Ignore:
Timestamp:
03/13/2025 12:50:53 PM (19 months ago)
Author:
SirLouen

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #56992, comment 42

    v6 v7  
    3838`Retrieves the next post, sets up the post, sets the 'in the loop' property to true.`
    3939
    40 The key part is picking up the "sets up the post". It all started in the `WP_Query::next_post()` method, with the `iterate current post index` and this has been tricking me for the whole time as a massive performance issue. I noticed that many sites were using the previous implementation, "benefiting" of this "unexpected behaviour" with the fact that since full posts were not retrieved, even after the initialization of the loop, you could just retrieve single elements like `get_the_title` and `get_the_permalink` for example for listings within the loop, with some gains in performance as I showed in my tests.
     40The key part is picking up the "sets up the post". It all started in the `WP_Query::next_post()` method, with the `iterate current post index` and this has been tricking me for the whole time as a massive performance issue. I noticed that many sites were using the previous implementation, "benefiting" of this "unexpected behaviour" with the fact that since full posts were not retrieved, even after the initialization of the loop, you could just retrieve single elements like `get_the_title` and `get_the_permalink` for example for listings within the loop, with some little gains in performance as I showed in my tests
    4141
    4242So we can consider that the expected behavior is that global post should be completely hydrated, despite that the WP_Query only received the stdClass with the ID for performance purposes. A very tricky scenario. I had to build all the code by myself to get this picture and compare the two scenarios. A little frustrating and particularly hard to test (without blindly accepting the proposed unit-tests, obviously).