View Issue Details

IDProjectCategoryView StatusLast Update
0006240mantisbtsqlpublic2008-10-18 18:34
ReporterDGtlRift Assigned ToDGtlRift  
PrioritylowSeveritytweakReproducibilityalways
Status closedResolutionno change required 
Product Versiongit trunk 
Summary0006240: db_unixtimestamp and ADODB
Description

really isn't mantis, it seems like it's actually ADODB, but I have a work around shown in the Add-Info.

The issue is that a call like db_unixtimestamp( db_timestamp() ) returns false. It seems that the string with the single quotes returned from db_timestamp() is unhandled in the regex processing in the UnixTimeStamp method used within.

Additional Information
    function db_unixtimestamp( $p_date=null ) {
            global $g_db;

            if ( null !== $p_date ) {
                    $p_timestamp = $g_db->UnixTimeStamp($p_date);
                    if ( !$p_timestamp ) {
                            $p_timestamp = $g_db->UnixTimeStamp(str_replace("'", "", $p_date ));
                    }
            } else {
                    $p_timestamp = time();
            }
            return $p_timestamp ;
    }
TagsNo tags attached.
Attached Files
timestamp.patch (964 bytes)   
? timestamp.patch
Index: core/database_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/database_api.php,v
retrieving revision 1.58
diff -u -B -w -r1.58 database_api.php
--- core/database_api.php	22 Jul 2007 21:02:45 -0000	1.58
+++ core/database_api.php	23 Jul 2007 13:38:04 -0000
@@ -492,12 +492,7 @@
 	function db_timestamp( $p_date=null ) {
 		global $g_db;
 
-		if ( null !== $p_date ) {
-			$p_timestamp = $g_db->UnixTimeStamp($p_date);
-		} else {
-			$p_timestamp = time();
-		}
-		return $g_db->DBTimeStamp($p_timestamp) ;
+		return $g_db->DBTimeStamp(db_unixtimestamp( $p_date )) ;
 	}
 
 	function db_unixtimestamp( $p_date=null ) {
@@ -505,6 +500,9 @@
 
 		if ( null !== $p_date ) {
 			$p_timestamp = $g_db->UnixTimeStamp($p_date);
+			if ( !$p_timestamp ) {
+				$p_timestamp = $g_db->UnixTimeStamp(str_replace("'", "", $p_date ));
+			}
 		} else {
 			$p_timestamp = time();
 		}
timestamp.patch (964 bytes)   

Activities

DGtlRift

DGtlRift

2007-07-23 09:42

reporter   ~0015181

I have submitted a patch. This issue can be resolved when someone with CVS write access does a peer review and patch integration to the source trunk.

grangeway

grangeway

2007-07-23 18:02

reporter   ~0015192

DGTlrift,

When does one see the issue this is trying to fix?

Paul

DGtlRift

DGtlRift

2007-07-23 21:07

reporter   ~0015197

We have proprietary add-ons that use the core API's, and in the script we use the g_some_global = db_timestamp() to generate a key for set scripts (that take a fair bit of time to run) that log info to the db using db_unixtimestamp(g_some_global) throughout.

giallu

giallu

2007-07-26 03:14

reporter   ~0015222

If this is an adoDB issue, can you also submit this upstream?

http://adodb.sourceforge.net/

DGtlRift

DGtlRift

2007-07-26 13:53

reporter   ~0015229

It seems like this is a fairly old issue..
http://phplens.com/lens/lensforum/msgs.php?id=13509&x=1

That nobody has posted an issue of on ADODB tracker...
until now
http://sourceforge.net/tracker/index.php?func=detail&aid=1761440&group_id=42718&atid=433976

giallu

giallu

2007-07-26 17:45

reporter   ~0015231

Thanks James: much appreciated

jreese

jreese

2008-02-07 23:11

reporter   ~0016981

Is this still an issue in trunk? db_timestamp() no longer matches the patch, but db_unixtimestamp() does. Is the second part of the patch still relevant?

jreese

jreese

2008-08-18 10:45

reporter   ~0019175

I'm closing this under the assumption that the fix is no longer needed.