Download & Extend

DateObject::limitGranularity() doesn't work when passed array contains zeroes

Project:Date
Version:7.x-2.x-dev
Component:Date API
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

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.

Comments

#1

Status:active» needs review

Fix and a test.

AttachmentSizeStatusTest resultOperations
date-1679552-1.patch2.03 KBIdlePASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es).View details | Re-test

#2

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.

#3

AttachmentSizeStatusTest resultOperations
fix_limitGranularity-1679552-3.patch520 bytesTest request sentNoneView details

#4

Merge test case with patch in #2.

AttachmentSizeStatusTest resultOperations
fix_limitGranularity-1679552-4.patch1.72 KBTest request sentNoneView details

#5

Change tab to spaces.

AttachmentSizeStatusTest resultOperations
fix_limitGranularity-1679552-5.patch1.75 KBTest request sentNoneView details
nobody click here