diff options
Diffstat (limited to 'program')
-rw-r--r-- | program/lib/Roundcube/rcube_config.php | 2 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_db.php | 36 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_db_mysql.php | 25 | ||||
-rw-r--r-- | program/steps/settings/edit_prefs.inc | 9 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 19 |
5 files changed, 66 insertions, 25 deletions
diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php index ac3ea678c..a3741758f 100644 --- a/program/lib/Roundcube/rcube_config.php +++ b/program/lib/Roundcube/rcube_config.php @@ -214,7 +214,7 @@ class rcube_config $success = true; } // deprecated name of config variable - else if (is_array($rcmail_config)) { + if (is_array($rcmail_config)) { $this->merge($rcmail_config); $success = true; } diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index 852070073..e66226ff5 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -386,17 +386,7 @@ class rcube_db $result = $this->dbh->query($query); if ($result === false) { - $error = $this->dbh->errorInfo(); - - if (empty($this->options['ignore_key_errors']) || $error[0] != '23000') { - $this->db_error = true; - $this->db_error_msg = sprintf('[%s] %s', $error[1], $error[2]); - - rcube::raise_error(array('code' => 500, 'type' => 'db', - 'line' => __LINE__, 'file' => __FILE__, - 'message' => $this->db_error_msg . " (SQL Query: $query)" - ), true, false); - } + $result = $this->handle_error($query); } $this->last_result = $result; @@ -405,6 +395,30 @@ class rcube_db } /** + * Helper method to handle DB errors. + * This by default logs the error but could be overriden by a driver implementation + * + * @param string Query that triggered the error + * @return mixed Result to be stored and returned + */ + protected function handle_error($query) + { + $error = $this->dbh->errorInfo(); + + if (empty($this->options['ignore_key_errors']) || $error[0] != '23000') { + $this->db_error = true; + $this->db_error_msg = sprintf('[%s] %s', $error[1], $error[2]); + + rcube::raise_error(array('code' => 500, 'type' => 'db', + 'line' => __LINE__, 'file' => __FILE__, + 'message' => $this->db_error_msg . " (SQL Query: $query)" + ), true, false); + } + + return false; + } + + /** * Get number of affected rows for the last query * * @param mixed $result Optional query handle diff --git a/program/lib/Roundcube/rcube_db_mysql.php b/program/lib/Roundcube/rcube_db_mysql.php index 6fa5ad768..24f9ce1bd 100644 --- a/program/lib/Roundcube/rcube_db_mysql.php +++ b/program/lib/Roundcube/rcube_db_mysql.php @@ -179,4 +179,29 @@ class rcube_db_mysql extends rcube_db return isset($this->variables[$varname]) ? $this->variables[$varname] : $default; } + /** + * Handle DB errors, re-issue the query on deadlock errors from InnoDB row-level locking + * + * @param string Query that triggered the error + * @return mixed Result to be stored and returned + */ + protected function handle_error($query) + { + $error = $this->dbh->errorInfo(); + + // retry after "Deadlock found when trying to get lock" errors + $retries = 2; + while ($error[1] == 1213 && $retries >= 0) { + usleep(50000); // wait 50 ms + $result = $this->dbh->query($query); + if ($result !== false) { + return $result; + } + $error = $this->dbh->errorInfo(); + $retries--; + } + + return parent::handle_error($query); + } + } diff --git a/program/steps/settings/edit_prefs.inc b/program/steps/settings/edit_prefs.inc index 468e4994d..adf6b1623 100644 --- a/program/steps/settings/edit_prefs.inc +++ b/program/steps/settings/edit_prefs.inc @@ -40,24 +40,21 @@ function rcmail_user_prefs_form($attrib) $out = $form_start; - foreach ($SECTIONS[$CURR_SECTION]['blocks'] as $block) { + foreach ($SECTIONS[$CURR_SECTION]['blocks'] as $class => $block) { if (!empty($block['options'])) { $table = new html_table(array('cols' => 2)); foreach ($block['options'] as $option) { - if ($option['advanced']) - $table->set_row_attribs('advanced'); - if (isset($option['title'])) { $table->add('title', $option['title']); - $table->add(null, $option['content']); + $table->add(null, $option['content']); } else { $table->add(array('colspan' => 2), $option['content']); } } - $out .= html::tag('fieldset', null, html::tag('legend', null, $block['name']) . $table->show($attrib)); + $out .= html::tag('fieldset', $class, html::tag('legend', null, $block['name']) . $table->show($attrib)); } else if (!empty($block['content'])) { $out .= html::tag('fieldset', null, html::tag('legend', null, $block['name']) . $block['content']); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index fdc07be9e..ecd35e94b 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -158,6 +158,7 @@ function rcmail_user_prefs($current = null) 'main' => array('name' => Q(rcube_label('mainoptions'))), 'skin' => array('name' => Q(rcube_label('skin'))), 'browser' => array('name' => Q(rcube_label('browseroptions'))), + 'advanced'=> array('name' => Q(rcube_label('advancedoptions'))), ); // language selection @@ -367,6 +368,7 @@ function rcmail_user_prefs($current = null) $blocks = array( 'main' => array('name' => Q(rcube_label('mainoptions'))), 'new_message' => array('name' => Q(rcube_label('newmessage'))), + 'advanced' => array('name' => Q(rcube_label('advancedoptions'))), ); // show config parameter for preview pane @@ -488,6 +490,7 @@ function rcmail_user_prefs($current = null) case 'mailview': $blocks = array( 'main' => array('name' => Q(rcube_label('mainoptions'))), + 'advanced' => array('name' => Q(rcube_label('advancedoptions'))), ); // show checkbox to open message view in new window @@ -543,7 +546,7 @@ function rcmail_user_prefs($current = null) $field_id = 'rcmfd_default_charset'; - $blocks['main']['options']['default_charset'] = array( + $blocks['advanced']['options']['default_charset'] = array( 'title' => html::label($field_id, Q(rcube_label('defaultcharset'))), 'content' => $RCMAIL->output->charset_selector(array( 'id' => $field_id, 'name' => '_default_charset', 'selected' => $config['default_charset'] @@ -605,6 +608,7 @@ function rcmail_user_prefs($current = null) 'main' => array('name' => Q(rcube_label('mainoptions'))), 'sig' => array('name' => Q(rcube_label('signatureoptions'))), 'spellcheck' => array('name' => Q(rcube_label('spellcheckoptions'))), + 'advanced' => array('name' => Q(rcube_label('advancedoptions'))), ); // show checkbox to compose messages in a new window @@ -673,8 +677,7 @@ function rcmail_user_prefs($current = null) $select->add(rcube_label('miscfolding'), 1); $select->add(rcube_label('2047folding'), 2); - $blocks['main']['options']['mime_param_folding'] = array( - 'advanced' => true, + $blocks['advanced']['options']['mime_param_folding'] = array( 'title' => html::label($field_id, Q(rcube_label('mimeparamfolding'))), 'content' => $select->show($config['mime_param_folding']), ); @@ -688,8 +691,7 @@ function rcmail_user_prefs($current = null) $field_id = 'rcmfd_force_7bit'; $input = new html_checkbox(array('name' => '_force_7bit', 'id' => $field_id, 'value' => 1)); - $blocks['main']['options']['force_7bit'] = array( - 'advanced' => true, + $blocks['advanced']['options']['force_7bit'] = array( 'title' => html::label($field_id, Q(rcube_label('force7bit'))), 'content' => $input->show($config['force_7bit']?1:0), ); @@ -866,7 +868,8 @@ function rcmail_user_prefs($current = null) // Addressbook config case 'addressbook': $blocks = array( - 'main' => array('name' => Q(rcube_label('mainoptions'))), + 'main' => array('name' => Q(rcube_label('mainoptions'))), + 'advanced' => array('name' => Q(rcube_label('advancedoptions'))), ); if (!isset($no_override['default_addressbook']) @@ -962,7 +965,8 @@ function rcmail_user_prefs($current = null) // Special IMAP folders case 'folders': $blocks = array( - 'main' => array('name' => Q(rcube_label('mainoptions'))), + 'main' => array('name' => Q(rcube_label('mainoptions'))), + 'advanced' => array('name' => Q(rcube_label('advancedoptions'))), ); if (!isset($no_override['show_real_foldernames'])) { @@ -1043,6 +1047,7 @@ function rcmail_user_prefs($current = null) $blocks = array( 'main' => array('name' => Q(rcube_label('mainoptions'))), 'maintenance' => array('name' => Q(rcube_label('maintenance'))), + 'advanced' => array('name' => Q(rcube_label('advancedoptions'))), ); if (!isset($no_override['read_when_deleted'])) { |