[wp-trac] [WordPress Trac] #41446: The PHP notice displayed after the overwriting global $posts by a new empty query.
WordPress Trac
noreply at wordpress.org
Wed Jul 26 12:42:22 UTC 2017
#41446: The PHP notice displayed after the overwriting global $posts by a new empty
query.
-----------------------------+------------------------------
Reporter: danielpietrasik | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.8
Severity: normal | Resolution:
Keywords: | Focuses:
-----------------------------+------------------------------
Comment (by danielpietrasik):
Using empty() function wouldn't be redundant security?
Of course it is correct, but unnecessary. {{{$this->post_count > 0}}} will
always return false if the variable is empty. Could you give me some
example when the {{{$this->post_count > 0}}} will return true if the
variable is empty.
Replying to [comment:1 umangvaghela123]:
> It`s is fine If we check !empty condition.
>
> {{{#!php
> <?php
> public function rewind_posts() {
> $this->current_post = -1;
> if ( isset( $this->posts[0] ) && !empty( $this->posts[0] ) &&
$this->post_count > 0 ) {
> $this->post = $this->posts[0];
> }
> }
> }}}
>
>
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41446#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list