- Simplified/reorganized version of patch #9620 by Jeremy: fixed errors when writing to cache.
parent
dbead89c1f
commit
503c784557
|
@ -148,7 +148,7 @@ function cache_set($cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) {
|
|||
|
||||
db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid);
|
||||
if (!db_affected_rows()) {
|
||||
db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s')", $cid, $data, time(), $expire, $headers);
|
||||
@db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s')", $cid, $data, time(), $expire, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -390,15 +390,19 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
|
|||
*/
|
||||
|
||||
/**
|
||||
* Log errors in the database rather than displaying them to the user.
|
||||
* Log errors as defined by administrator
|
||||
* Error levels:
|
||||
* 1 = Log errors to database.
|
||||
* 2 = Log errors to database and to screen.
|
||||
*/
|
||||
function error_handler($errno, $message, $filename, $line, $variables) {
|
||||
$types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning');
|
||||
$entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.';
|
||||
if ($errno & E_ALL ^ E_NOTICE) {
|
||||
$types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning');
|
||||
$entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.';
|
||||
|
||||
if ($errno & (E_ALL ^ E_NOTICE)) {
|
||||
watchdog('error', t('%error: %message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line)));
|
||||
if (error_reporting()) {
|
||||
|
||||
if (variable_get('error_level', 1) == 1) {
|
||||
print '<pre>'. $entry .'</pre>';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ function node_tag_new($nid) {
|
|||
db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', time(), $user->uid, $nid);
|
||||
}
|
||||
else {
|
||||
db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, time());
|
||||
@db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, time());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ function node_tag_new($nid) {
|
|||
db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', time(), $user->uid, $nid);
|
||||
}
|
||||
else {
|
||||
db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, time());
|
||||
@db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, time());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,16 +185,19 @@ function system_view_general() {
|
|||
$group .= form_textarea(t('Footer message'), 'site_footer', variable_get('site_footer', ''), 70, 5, t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.'));
|
||||
$group .= form_textfield(t('Anonymous user'), 'anonymous', variable_get('anonymous', 'Anonymous'), 70, 70, t('The name used to indicate anonymous users.'));
|
||||
$group .= form_textfield(t('Default front page'), 'site_frontpage', variable_get('site_frontpage', 'node'), 70, 70, t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".'));
|
||||
$group .= form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable clean URLs. If enabled, you\'ll need <code>ModRewrite</code> support. See also the <code>.htaccess</code> file in Drupal\'s top-level directory.'));
|
||||
|
||||
// watchdog setting:
|
||||
$output = form_group(t('General settings'), $group);
|
||||
|
||||
// error handling:
|
||||
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
|
||||
$period['1000000000'] = t('Never');
|
||||
$group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
|
||||
$group = form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_select(t('Error reporting'), 'error_level', variable_get('error_level', 1), array('Write errors to the log', 'Write errors to the log and to the screen'), t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.'));
|
||||
$group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
|
||||
|
||||
$output = form_group(t('General settings'), $group);
|
||||
$output .= form_group(t('Error handling'), $group);
|
||||
|
||||
// caching:
|
||||
$group = form_radios(t('Cache support'), 'cache', variable_get('cache', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable the caching of rendered pages. When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately. Check the <a href="%documentation">cache documentation</a> for information on Drupal\'s cache system.', array('%documentation' => url('admin/help', NULL, NULL, 'cache'))));
|
||||
|
|
|
@ -185,16 +185,19 @@ function system_view_general() {
|
|||
$group .= form_textarea(t('Footer message'), 'site_footer', variable_get('site_footer', ''), 70, 5, t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.'));
|
||||
$group .= form_textfield(t('Anonymous user'), 'anonymous', variable_get('anonymous', 'Anonymous'), 70, 70, t('The name used to indicate anonymous users.'));
|
||||
$group .= form_textfield(t('Default front page'), 'site_frontpage', variable_get('site_frontpage', 'node'), 70, 70, t('The home page displays content from this relative URL. If you are not using clean URLs, specify the part after "?q=". If unsure, specify "node".'));
|
||||
$group .= form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable clean URLs. If enabled, you\'ll need <code>ModRewrite</code> support. See also the <code>.htaccess</code> file in Drupal\'s top-level directory.'));
|
||||
|
||||
// watchdog setting:
|
||||
$output = form_group(t('General settings'), $group);
|
||||
|
||||
// error handling:
|
||||
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
|
||||
$period['1000000000'] = t('Never');
|
||||
$group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time watchdog entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
|
||||
$group = form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document. If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
|
||||
$group .= form_select(t('Error reporting'), 'error_level', variable_get('error_level', 1), array('Write errors to the log', 'Write errors to the log and to the screen'), t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.'));
|
||||
$group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time log entries should be kept. Older entries will be automatically discarded. Requires crontab.'));
|
||||
|
||||
$output = form_group(t('General settings'), $group);
|
||||
$output .= form_group(t('Error handling'), $group);
|
||||
|
||||
// caching:
|
||||
$group = form_radios(t('Cache support'), 'cache', variable_get('cache', 0), array(t('Disabled'), t('Enabled')), t('Enable or disable the caching of rendered pages. When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately. Check the <a href="%documentation">cache documentation</a> for information on Drupal\'s cache system.', array('%documentation' => url('admin/help', NULL, NULL, 'cache'))));
|
||||
|
|
Loading…
Reference in New Issue