BUGFIX: fix mysql insert statements (null values for timestamps didn't work anymore)
authorArun Persaud <arun@nubati.net>
Mon, 5 Oct 2015 00:03:34 +0000 (17:03 -0700)
committerArun Persaud <arun@nubati.net>
Mon, 5 Oct 2015 00:05:32 +0000 (17:05 -0700)
a dreamhost update to a newer sql version changed the default behavior for
null inserts for timestamps. They don't insert the current timestamp anymore
when a config option for mysql is set (which seems to be the case).

solution: instead of inserting null always insert current_timestamp

include/db.php
include/game.php
include/newgame.php
include/register.php

index 2ea2ac0a1dca2b7aa7c6f10e6a16c272b6f9588f..b84a3aeef7e2b4bedc8096e4e78f764b7c1fae13 100644 (file)
@@ -379,7 +379,7 @@ function DB_get_current_trickid($gameid)
 
   if(!$sequence || $sequence==4)
     {
-      DB_query("INSERT INTO Trick VALUES (NULL,NULL,NULL, ".DB_quote_smart($gameid).",NULL)");
+      DB_query("INSERT INTO Trick VALUES (CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,NULL,".DB_quote_smart($gameid).",NULL)");
       $trickid  = DB_insert_id();
       $sequence = 1;
       $number++;
@@ -401,7 +401,7 @@ function DB_get_max_trickid($gameid)
 
 function DB_play_card($trickid,$handcardid,$sequence)
 {
-  DB_query("INSERT INTO Play VALUES(NULL,NULL,NULL,".DB_quote_smart($trickid).
+  DB_query("INSERT INTO Play VALUES(CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,NULL,".DB_quote_smart($trickid).
           ",".DB_quote_smart($handcardid).",".DB_quote_smart($sequence).")");
 
   $playid = DB_insert_id();
@@ -570,7 +570,7 @@ function DB_get_user_timezone($userid)
 
 function DB_insert_comment($comment,$playid,$gameid,$userid)
 {
-  DB_query("INSERT INTO Comment VALUES (NULL,NULL,NULL,$userid,$playid,$gameid, ".DB_quote_smart($comment).")");
+  DB_query("INSERT INTO Comment VALUES (CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,NULL,$userid,$playid,$gameid, ".DB_quote_smart($comment).")");
 
   return;
 }
@@ -595,7 +595,7 @@ function DB_get_pre_comment_call($gameid)
 
 function DB_insert_note($comment,$gameid,$userid)
 {
-  DB_query("INSERT INTO Notes VALUES (NULL,NULL,NULL,$userid,$gameid, ".DB_quote_smart($comment).")");
+  DB_query("INSERT INTO Notes VALUES (CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,NULL,$userid,$gameid, ".DB_quote_smart($comment).")");
 
   return;
 }
@@ -736,7 +736,7 @@ function DB_get_ruleset($dullen,$schweinchen,$call,$lowtrump)
   else
     {
       /* create new one */
-      $result = DB_query("INSERT INTO Rulesets VALUES (NULL, NULL, ".
+      $result = DB_query("INSERT INTO Rulesets VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ".
                         DB_quote_smart($dullen).",".
                         DB_quote_smart($schweinchen).",".
                         DB_quote_smart($lowtrump).",".
@@ -944,7 +944,7 @@ function DB_get_number_of_passwords_recovery($user)
 function DB_set_recovery_password($user,$newpw)
 {
   DB_query("INSERT INTO Recovery VALUES(NULL,".DB_quote_smart($user).
-          ",".DB_quote_smart($newpw).",NULL)");
+          ",".DB_quote_smart($newpw).",CURRENT_TIMESTAMP)");
   return;
 }
 
@@ -1052,7 +1052,7 @@ function DB_set_reminder($user,$gameid)
 {
   DB_query("INSERT INTO Reminder ".
           "  VALUES(NULL, ".DB_quote_smart($user).", ".DB_quote_smart($gameid).
-          ", NULL) ");
+          ", CURRENT_TIMESTAMP) ");
   return 0;
 }
 
@@ -1249,9 +1249,9 @@ function DB_get_number_of_tricks($gameid,$position)
 function DB_digest_insert_email($To,$message,$type,$gameid)
 {
   if($type == GAME_YOUR_TURN)
-    DB_query("INSERT INTO digest_email VALUES (NULL,".DB_quote_smart($To).",NULL,'your_turn',$gameid,".DB_quote_smart($message).")");
+    DB_query("INSERT INTO digest_email VALUES (NULL,".DB_quote_smart($To).",CURRENT_TIMESTAMP,'your_turn',$gameid,".DB_quote_smart($message).")");
   else
-    DB_query("INSERT INTO digest_email VALUES (NULL,".DB_quote_smart($To).",NULL,'misc',NULL,".DB_quote_smart($message).")");
+    DB_query("INSERT INTO digest_email VALUES (NULL,".DB_quote_smart($To).",CURRENT_TIMESTAMP,'misc',NULL,".DB_quote_smart($message).")");
   return;
 }
 
index 88158b991840e7b63e80223ecef6076d74c02979..9028364e93bec14ae740ba02d2e64a4d2045e8c1 100644 (file)
@@ -1577,7 +1577,7 @@ switch($mystatus)
 
                            if($party1 != $party2)
                              DB_query("INSERT INTO Score".
-                                      " VALUES( NULL,NULL,$gameid,'$party1',$uid1,$uid2,'fox')");
+                                      " VALUES(NULL,CURRENT_TIMESTAMP,$gameid,'$party1',$uid1,$uid2,'fox')");
                          }
                    }
 
@@ -1602,7 +1602,7 @@ switch($mystatus)
                                $party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
 
                                DB_query("INSERT INTO Score".
-                                        " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'karlchen')");
+                                        " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'$party1',$uid1,NULL,'karlchen')");
                              };
                      };
                  }; /* end scoring Karlchen */
@@ -1622,7 +1622,7 @@ switch($mystatus)
                    $party1 = DB_get_party_by_gameid_and_userid($gameid,$uid1);
 
                    DB_query("INSERT INTO Score".
-                            " VALUES( NULL,NULL,$gameid,'$party1',$uid1,NULL,'doko')");
+                            " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'$party1',$uid1,NULL,'doko')");
                  }
 
                /*
@@ -1835,14 +1835,14 @@ switch($mystatus)
                    for( $p=$call_contra;$p<=120; $p+=30 )
                      {
                          DB_query('INSERT INTO Score'.
-                                  " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'against$p')");
+                                  " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'against$p')");
                        }
 
                      for( $p=$call_contra; $p<120; $p+=30)
                        {
                          if( $re >= $p )
                            DB_query('INSERT INTO Score'.
-                                    " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'made$p')");
+                                    " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'made$p')");
                        }
                    }
                  if($winning_party!='re' and $call_re!= -1)
@@ -1850,14 +1850,14 @@ switch($mystatus)
                      for( $p=$call_re;$p<=120; $p+=30 )
                        {
                          DB_query('INSERT INTO Score'.
-                                  " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'against$p')");
+                                  " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'against$p')");
                        }
 
                      for( $p=$call_re; $p<120; $p+=30)
                        {
                          if( $contra>=$p )
                            DB_query('INSERT INTO Score'.
-                                    " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'made$p')");
+                                    " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'made$p')");
                        }
                    }
 
@@ -1865,7 +1865,7 @@ switch($mystatus)
                  if($winning_party=='contra')
                    {
                      DB_query('INSERT INTO Score'.
-                              " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'againstqueens')");
+                              " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'againstqueens')");
                    }
 
                  /* one point each for winning and each 30 points + calls */
@@ -1879,14 +1879,14 @@ switch($mystatus)
 
                          if($re>$p-$offset)
                            DB_query('INSERT INTO Score'.
-                                    " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'".(240-$p)."')");
+                                    " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'".(240-$p)."')");
                        }
                      /* re called something and won */
                      foreach(array(0,30,60,90,120) as $p)
                        {
                          if($call_re!= -1 && $call_re<$p+1)
                            DB_query('INSERT INTO Score'.
-                                    " VALUES( NULL,NULL,$gameid,'re',NULL,NULL,'call$p')");
+                                    " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'re',NULL,NULL,'call$p')");
                        }
                    }
                  else if( $winning_party=='contra')
@@ -1899,14 +1899,14 @@ switch($mystatus)
 
                          if($contra>$p-$offset)
                            DB_query('INSERT INTO Score'.
-                                    " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
+                                    " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'".(240-$p)."')");
                        }
                      /* re called something and won */
                      foreach(array(0,30,60,90,120) as $p)
                        {
                          if($call_contra != -1 && $call_contra<$p+1)
                            DB_query('INSERT INTO Score'.
-                                    " VALUES( NULL,NULL,$gameid,'contra',NULL,NULL,'call$p')");
+                                    " VALUES( NULL,CURRENT_TIMESTAMP,$gameid,'contra',NULL,NULL,'call$p')");
                        }
                    };
 
index 1dd056d81aced5d939fbf7b3b14e8684c53efb53..eb0dbdb5b2585477a746c1a10c81743d7edbfc9c 100644 (file)
@@ -128,7 +128,7 @@ else
              }
 
            if($session)
-             DB_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
+             DB_query("INSERT INTO Game VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
                       "'$ruleset','$session' ,NULL)");
            else
              {
@@ -136,7 +136,7 @@ else
                $max = DB_get_max_session();
                $max++;
                DB_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
-               DB_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
+               DB_query("INSERT INTO Game VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
                            "'$ruleset','$max' ,NULL)");
              }
          }
@@ -153,7 +153,7 @@ else
            $max = DB_get_max_session();
            $max++;
 
-           DB_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre', ".
+           DB_query("INSERT INTO Game VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre', ".
                     "'$ruleset','$max' ,NULL)");
          }
        $gameid = DB_insert_id();
index 028e1bb278dd62af2ffb8dd4bc422aa8de074bfc..d0b18b1ee951d12bef0c4aeac3b57b625360720d 100644 (file)
@@ -113,7 +113,7 @@ if(myisset('Rfullname','Remail','Rtimezone') )
                $r=DB_query('INSERT INTO User VALUES(NULL,'.DB_quote_smart($_REQUEST['Rfullname']).
                            ','.DB_quote_smart($_REQUEST['Remail']).
                            ','.DB_quote_smart($hash).
-                           ','.DB_quote_smart($_REQUEST['Rtimezone']).',NULL,NULL)');
+                           ','.DB_quote_smart($_REQUEST['Rtimezone']).',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)');
              }
            else /* hash function didn't work */
              $r=0;
@@ -124,7 +124,7 @@ if(myisset('Rfullname','Remail','Rtimezone') )
            $r=DB_query('INSERT INTO User VALUES(NULL,'.DB_quote_smart($_REQUEST['Rfullname']).
                        ','.DB_quote_smart($_REQUEST['Remail']).
                        ','.DB_quote_smart(md5($password)).
-                       ','.DB_quote_smart($_REQUEST['Rtimezone']).',NULL,NULL)');
+                       ','.DB_quote_smart($_REQUEST['Rtimezone']).',CURRENT_TIMESTAMP,CURRENT_TIMESTAMP)');
            if($r)
              {
                include_once('openid.php');