[wp-trac] [WordPress Trac] #31067: WP_Date_Query - broken hour-validation

WordPress Trac noreply at wordpress.org
Wed Jan 21 06:06:31 UTC 2015


#31067: WP_Date_Query - broken hour-validation
------------------------------------------+---------------------------
 Reporter:  ChriCo                        |       Owner:  boonebgorges
     Type:  defect (bug)                  |      Status:  reopened
 Priority:  normal                        |   Milestone:  4.1.1
Component:  Query                         |     Version:  4.1
 Severity:  normal                        |  Resolution:
 Keywords:  has-patch commit fixed-major  |     Focuses:
------------------------------------------+---------------------------

Comment (by ChriCo):

 Why adding an ''is_numeric''-Check
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/date.php?rev=31251#L397 here], when already one is
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/date.php?rev=31251#L423 there] ?

 Maybe we should also consider, if its a good way to move some checks out
 of the class and to the formattings.php. Something like this:


 {{{
 /**
  * Verifies that the given value is a valid hour.
  *
  * @since 4.1.1
  *
  * @param int|string $value
  * @return bool true|false
 */
 function is_hour( $value ) {

         if ( ! is_numeric( $value ) ) {
                 return false;
         }

         if ( $value < 0 || $value > 23 ) {
                 return false;
         }

         return true;
 }
 }}}

 same for: year, day, dayofweek, dayofyear, month, minute, second and week.

 Week and dayofyear needs a second param "year" for a strict check.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31067#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list