-
Notifications
You must be signed in to change notification settings - Fork 3.2k
AJAX request returns critical error in class-wp-date-query.php #5108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| */ | ||
| if ( is_array( $date_query['year'] ) ) { | ||
| $_year = reset( $date_query['year'] ); | ||
| $_year = intval(reset( $date_query['year'] )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $_year = intval(reset( $date_query['year'] )); | |
| $_year = intval( reset( $date_query['year'] ) ); |
| */ | ||
| if ( is_array( $date_query['year'] ) ) { | ||
| $_year = reset( $date_query['year'] ); | ||
| $_year = intval( reset( $date_query['year'] )) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $_year = intval( reset( $date_query['year'] )) ; | |
| $_year = intval( reset( $date_query['year'] ) ); |
| $_year = intval( reset( $date_query['year'] )) ; | ||
| } else { | ||
| $_year = $date_query['year']; | ||
| $_year = intval( $date_query['year']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $_year = intval( $date_query['year']); | |
| $_year = intval( $date_query['year'] ); |
| */ | ||
| if ( is_array( $date_query['year'] ) ) { | ||
| $_year = reset( $date_query['year'] ); | ||
| $_year = intval( reset( $date_query['year'] )) ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset() can return false. I think the condition wrapping this should probably be adjusted to also check for a non-empty array to avoid this.
Also, please do not use intval() except as a callback. A simple (int) cast is better.
| $_year = intval( reset( $date_query['year'] )) ; | ||
| } else { | ||
| $_year = $date_query['year']; | ||
| $_year = intval( $date_query['year']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing: please use (int) instead of intval().
Fixes this error: PHP Fatal error: Uncaught TypeError: mktime(): Argument #6 ($year) must be of type ?int, string given in /wp-includes/class-wp-date-query.php:320
Trac ticket: https://core.trac.wordpress.org/ticket/59235