php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #57310 timezonedb_external load old timezonedb_idx_builtin and timelib_timezone_db_data
Submitted: 2006-10-20 10:05 UTC Modified: 2006-10-27 14:11 UTC
From: marcus at corp dot grupos dot com dot br Assigned: derick (profile)
Status: Closed Package: timezonedb (PECL)
PHP Version: 5.1.6 OS: FreeBSD
Private report: No CVE-ID: None
 [2006-10-20 10:05 UTC] marcus at corp dot grupos dot com dot br
Description:
------------
2006.14 need to be updated. Since tzdata-2006n are released.

tzdata-2006n contain update for America/Sao_Paulo.

# date
Sex 20 Out 2006 11:03:26 BRT
# php tz.php 
date_default_timezone_get: America/Sao_Paulo
date('j-m-Y H:i:s TP'): 20-10-2006 12:03:36 BRST-02:00

Reproduce code:
---------------
<?php

echo "date_default_timezone_get: ".date_default_timezone_get()."\n";
echo "date('j-m-Y H:i:s TP'): ".date("j-m-Y H:i:s TP")."\n";

?>

Expected result:
----------------
date_default_timezone_get: America/Sao_Paulo
date('j-m-Y H:i:s TP'): 20-10-2006 12:03:36 BRT-03:00

Actual result:
--------------
date_default_timezone_get: America/Sao_Paulo
date('j-m-Y H:i:s TP'): 20-10-2006 12:03:36 BRST-02:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-20 10:47 UTC] derick@php.net
2006.14 is already the latest version. But I need to use numbers in versions, and the n is the 14th letter in the alphabet. Your code executes fine here:

derick@kossu:~$ export TZ=America/Sao_Paulo
derick@kossu:~$ date
Fri Oct 20 12:45:45 BRST 2006
derick@kossu:~$ php
<?php

echo "date_default_timezone_get: ".date_default_timezone_get()."\n";
echo "date('j-m-Y H:i:s TP'): ".date("j-m-Y H:i:s TP")."\n";

?>
date_default_timezone_get: America/Sao_Paulo
date('j-m-Y H:i:s TP'): 20-10-2006 11:45:57 BRT-03:00
 [2006-10-20 14:14 UTC] marcus at corp dot grupos dot com dot br
I don't know what's wrong. See below.

-- php --
<?php

function parsePHPModules() {
 ob_start();
 phpinfo(INFO_MODULES);
 $s = ob_get_contents();
 ob_end_clean();
 
 $s = strip_tags($s,'<h2><th><td>');
 $s = preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$s);
 $s = preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$s);
 $vTmp = preg_split('/(<h2>[^<]+<\/h2>)/',$s,-1,PREG_SPLIT_DELIM_CAPTURE);
 $vModules = array();
 for ($i=1;$i<count($vTmp);$i++) {
  if (preg_match('/<h2>([^<]+)<\/h2>/',$vTmp[$i],$vMat)) {
   $vName = trim($vMat[1]);
   $vTmp2 = explode("\n",$vTmp[$i+1]);
   foreach ($vTmp2 AS $vOne) {
   $vPat = '<info>([^<]+)<\/info>';
   $vPat3 = "/$vPat\s*$vPat\s*$vPat/";
   $vPat2 = "/$vPat\s*$vPat/";
   if (preg_match($vPat3,$vOne,$vMat)) { // 3cols
     $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
   } elseif (preg_match($vPat2,$vOne,$vMat)) { // 2cols
     $vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
   }
   }
  }
 }
 return $vModules;
}

echo "date_default_timezone_get: ".date_default_timezone_get()."<br>\n";
echo "date('j-m-Y H:i:s TP'): ".date("j-m-Y H:i:s TP")."<br>\n";
echo "system('date'): ";
system('date');
echo "<br>\n";
echo "<pre>\n";
$p = parsePHPModules();
print_r($p['date']);
print_r($p['timezonedb']);
echo "</pre>\n";

?>
--

Result:
http://intranet.grupos.com.br/~marcus/tz.php
 [2006-10-25 16:32 UTC] marcus at corp dot grupos dot com dot br
Ok. i found the bug.

In timezonedb.c there's a one define that create timezonedb_external.

#define  timezonedb_builtin timezonedb_external

But in timezonedb.h he include timezonedb_idx_builtin and timelib_timezone_db_data_builtin. Because that need two more defines in timezonedb.c.

-- PATCH --
--- timezonedb.c.orig	Wed Oct 25 17:25:03 2006
+++ timezonedb.c	Wed Oct 25 17:25:43 2006
@@ -29,6 +29,8 @@
 
 #include "ext/date/php_date.h"
 
+#define  timezonedb_idx_builtin timezonedb_idx_external
+#define  timelib_timezone_db_data_builtin timelib_timezone_db_data_external
 #define  timezonedb_builtin timezonedb_external
 #include "timezonedb.h"

-- PATCH --
 [2006-10-27 14:11 UTC] derick@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

And thanks for your details on this!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 07:01:29 2024 UTC