Explorar o código

[ZF-11610] Added string cast to ctype_digit call in Zend_Gdata_App_Util

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24643 44c647ce-9c0f-0410-b52a-842ac1e357ba
adamlundrigan %!s(int64=14) %!d(string=hai) anos
pai
achega
eb36dac0c7
Modificáronse 2 ficheiros con 12 adicións e 1 borrados
  1. 1 1
      library/Zend/Gdata/App/Util.php
  2. 11 0
      tests/Zend/Gdata/App/UtilTest.php

+ 1 - 1
library/Zend/Gdata/App/Util.php

@@ -45,7 +45,7 @@ class Zend_Gdata_App_Util
         $rfc3339 = '/^(\d{4})\-?(\d{2})\-?(\d{2})((T|t)(\d{2})\:?(\d{2})' .
                    '\:?(\d{2})(\.\d{1,})?((Z|z)|([\+\-])(\d{2})\:?(\d{2})))?$/';
 
-        if (ctype_digit($timestamp)) {
+        if (ctype_digit((string)$timestamp)) {
             return gmdate('Y-m-d\TH:i:sP', $timestamp);
         } elseif (preg_match($rfc3339, $timestamp) > 0) {
             // timestamp is already properly formatted

+ 11 - 0
tests/Zend/Gdata/App/UtilTest.php

@@ -149,6 +149,17 @@ class Zend_Gdata_App_UtilTest extends PHPUnit_Framework_TestCase
         // Excetion not thrown, this is bad.
         $this->fail("Exception not thrown.");
     }
+    
+    /**
+     * @group ZF-11610
+     */
+    public function testFormatTimestepHandlesSmallUnixTimestampProperly()
+    {
+        $this->assertEquals(
+            '1970-01-01T00:02:03+00:00',
+            Zend_Gdata_App_Util::formatTimestamp(123)
+        );
+    }
 
     public function testFindGreatestBoundedValueReturnsMax() {
         $data = array(-1 => null,