When you pass field settings with at least one zero value to the DateObject::limitGranularity(), it doesn't filter out anything, because non-strict comparison returns match for any granularity string and integer zero.

Patch follows.

Files: 
CommentFileSizeAuthor
#5 fix_limitGranularity-1679552-5.patch1.75 KBbarami
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix_limitGranularity-1679552-5.patch. Unable to apply patch. See the log in the details link for more information. View
#4 fix_limitGranularity-1679552-4.patch1.72 KBbarami
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix_limitGranularity-1679552-4.patch. Unable to apply patch. See the log in the details link for more information. View
#3 fix_limitGranularity-1679552-3.patch520 bytesbarami
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es). View
#1 date-1679552-1.patch2.03 KBDmitriy.trt
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es). View

Comments

Dmitriy.trt’s picture

Status: Active » Needs review
FileSize
2.03 KB
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es). View

Fix and a test.

barami’s picture

I have same problem.
It needs to be accept.

Accepet above patch or change code using in_array function to add parameter 'strict' to TRUE.
http://php.net/manual/en/function.in-array.php

default 'strict' parameter is FALSE and it searchs on array keys too.
So, limitGranularity functions always don't remove granularity part.

barami’s picture

FileSize
520 bytes
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es). View
barami’s picture

FileSize
1.72 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix_limitGranularity-1679552-4.patch. Unable to apply patch. See the log in the details link for more information. View

Merge test case with patch in #2.

barami’s picture

FileSize
1.75 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fix_limitGranularity-1679552-5.patch. Unable to apply patch. See the log in the details link for more information. View

Change tab to spaces.

Status: Needs review » Needs work

The last submitted patch, fix_limitGranularity-1679552-5.patch, failed testing.