breggen
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: WP_Query not always returning postsOk, so I changed the query function to look like :
public function query( $query ) { $this->init(); $this->query = $this->query_vars = wp_parse_args( $query ); $this->get_posts(); return $this->posts; }
That fixed the problem and now both calls return products. Only one problem now is that the call from the admin panel returns 4 products and the cronjob call returns 2 products. The difference is that the admin panel call also returns products that are member only and the cronjob call doesn’t include the member only products.
But this is a whole other problem, possibly to do with the query variables I can pass to the query.
One down, the rest to go.
Forum: Fixing WordPress
In reply to: WP_Query not always returning postsWell the mystery deepens it seems. I spent yesterday evening further debugging this issue and some strange things happen, which lead me to believe that there might be something going on in PHP. Apart from the problem described above I also found the following ( i will show only a small snippet of WP_Query class )
public function query( $query ) { $this->init(); $this->query = $this->query_vars = wp_parse_args( $query ); return $this->get_posts(); }
As you can see it will call $this->get_posts() and return whatever it gives back. At the end of the get_posts function the return looks like this
return $this->posts;
So in this function it will manipulate the $this->posts class variable and return it to the caller. While this all looks nice, the following actually happens:
The function return nothing ( or null have not checked that ) but the $this->posts actually contains the manipulated posts. This is just as strange as the first problem I found.Stranger still is that when calling the function from the admin panel all works as expected. I will need to check how WP calls its cronjob. Maybe this is done by externally calling PHP with the wp_cron.php as script?? I have no clue at this moment. I will also try and upgrade PHP to the latest version, maybe this is a known bug or so.
To be continued
Forum: Fixing WordPress
In reply to: WP_Query not always returning postsI mean a WordPress Cron. It gets loaded when a page loads. Or I can trigger it through the use of the Advanced Cron Manager plugin.