Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #52386, comment 2


Ignore:
Timestamp:
04/30/2024 06:31:15 AM (19 months ago)
Author:
oglekler
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #52386, comment 2

    initial v1  
    11This method cannot be made private because it will break a lot of themes and plugins actually leading to a disaster, but I believe that there is an easy fix — this method is not getting any arguments, so, there is no way that the result can be changed (apart from a possibility that before WP_Query() object creation and this method call some data will be changed by something else, but I think it should be fine not to count in most cases this method call is the next line after object initialization. And $posts property initially is equal to null, so, if $this->posts is an array, even an empty one, we can safely return this array on the spot without processing the query again.
    22
     3But if setter is used in between object initialization and get_posts(), the outcome can be different, so it is getting complicated, but any change to the query_vars can raise a flag that change had happened and send get_posts to fully processing the query, but such cases should be in minority.
     4
    35@costdev what do you think? 🙏
     6