]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add better debugging
authorEvan Prodromou <evan@controlezvous.ca>
Sun, 22 Jun 2008 14:09:41 +0000 (10:09 -0400)
committerEvan Prodromou <evan@controlezvous.ca>
Sun, 22 Jun 2008 14:09:41 +0000 (10:09 -0400)
darcs-hash:20080622140941-34904-2a0eda21f6a374a9d26107a4bc627fc6de2a7063.gz

actions/confirmemail.php
actions/register.php
lib/util.php

index 8052452ae736ade0fd19a311f1c6df49d4554fcd..e69cc6fff8d2105c94cc71a1e3dc9bf640a1a8ed 100644 (file)
@@ -47,21 +47,27 @@ class ConfirmemailAction extends Action {
             $this->client_error(_t('That email address is already confirmed.'));
             return;
         }
+               
         $cur->query('BEGIN');
+               
         $orig_user = clone($cur);
         $cur->email = $confirm_email->email;
-        common_debug('cur email = "' . $cur->email . '"', __FILE__);
         $result = $cur->update($orig_user);
+               
         if (!$result) {
-            $this->server_error(_t('Error setting email address.'));
+                       common_log_db_error($cur, 'UPDATE', __FILE__);
             return;
         }
+               
         $result = $confirm_email->delete();
+               
         if (!$result) {
-            $this->server_error(_t('Error deleting code.'));
+                       common_log_db_error($confirm_email, 'DELETE', __FILE__);
             return;
         }
+               
         $cur->query('COMMIT');
+               
         common_show_header(_t('Confirm E-mail Address'));
         common_element('p', NULL,
                        _t('The email address "') . $cur->email . 
index 3ed892e7ff16798c991f4a77a20fc42f7b04087e..2bb4f12f0f9537213022bfe6ae4abe2d79057acf 100644 (file)
@@ -99,8 +99,10 @@ class RegisterAction extends Action {
                $profile->created = DB_DataObject_Cast::dateTime(); # current time
 
                $id = $profile->insert();
+               
                if (!$id) {
-                       return FALSE;
+                       common_log_db_error($profile, 'INSERT', __FILE__);
+                   return FALSE;
                }
                $user = new User();
                $user->id = $id;
@@ -110,11 +112,14 @@ class RegisterAction extends Action {
                $user->uri = common_user_uri($user);
                
                $result = $user->insert();
+               
                if (!$result) {
+                       common_log_db_error($user, 'INSERT', __FILE__);
                        return FALSE;
                }
 
                if ($email) {
+                       
                        $confirm = new Confirm_email();
                        $confirm->code = common_good_rand(16);
                        $confirm->user_id = $user->id;
@@ -122,6 +127,7 @@ class RegisterAction extends Action {
                        
                        $result = $confirm->insert();
                        if (!$result) {
+                               common_log_db_error($confirm, 'INSERT', __FILE__);
                                return FALSE;
                        }
                }
index ae6752653d5f19acd5baa7bee45036db5017549c..11b1bfd5e1bbeb73edd782bb88259a754e674135 100644 (file)
@@ -762,6 +762,25 @@ function common_debug($msg, $filename=NULL) {
        }
 }
 
+function common_log_db_error($object, $verb, $filename=NULL) {
+       $objstr = common_log_objstring($ojbect);
+       $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
+       common_log(LOG_ERROR, $last_error->message . '(' . $verb . ' on ' . $objstr . ')', $filename);
+}
+
+function common_log_objstring($object) {
+       if (is_null($object)) {
+               return "NULL";
+       }
+       $arr = $object->toArray();
+       $fields = array();
+       foreach ($arr as $k => $v) {
+               $fields[] = "$k='$v'";
+       }
+       $ojbstring = $object->tableName() . '[' . implode(',', $fields) . ']';
+       return $objstring;
+}
+
 function common_valid_http_url($url) {
        return Validate::uri($url, array('allowed_schemes' => array('http', 'https')));
 }