Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There are wrong condition in removeGranularity method, it doesnt work if I want to remove granularity with key '0' in granularity array.
Method code:
public function removeGranularity($g) {
if ($key = array_search($g, $this->granularity)) {
unset($this->granularity[$key]);
}
}
Test case:
$this->granularity = array(
0 => hour,
1 => minute,
2 => second
);
This method will not work If I want to remove 'hour' element:
$this->removeGranularity('hour');
because key of 'hour' element is '0', and ($key = array_search($g, $this->granularity))
condition is false
.
Comment | File | Size | Author |
---|---|---|---|
#7 | date-wrong_removeGranularity_condition-2359673-7.patch | 1.6 KB | skorzh |
Comments
Comment #1
skorzhMy little patch fixed it.
Test case:
Comment #2
skorzhNo updates here?
Comment #4
skorzhAdded more properly patch
Comment #5
SpleshkaTested this patch, now it works perfectly, thanks!
Comment #6
podarokPatch looks good.
But we have to cover it by test.
Please, add some
Comment #7
skorzhAdded tests, check please now
Comment #8
SpleshkaI like this test! So I believe now it is ready to be commited :-)
Comment #9
podarok#7 merged
Thanks!