Commit e5b0e5f7 authored by Dries's avatar Dries

- Patch #302763 by Dave Reid, Rob Loach: replace time() by ['REQUEST_TIME'] as...

- Patch #302763 by Dave Reid, Rob Loach: replace time() by ['REQUEST_TIME'] as per Rasmus' suggestion.  Removed drupal_referrer() for consistency.
parent cbb639a1
...@@ -707,15 +707,6 @@ function drupal_unpack($obj, $field = 'data') { ...@@ -707,15 +707,6 @@ function drupal_unpack($obj, $field = 'data') {
return $obj; return $obj;
} }
/**
* Return the URI of the referring page.
*/
function referer_uri() {
if (isset($_SERVER['HTTP_REFERER'])) {
return $_SERVER['HTTP_REFERER'];
}
}
/** /**
* Encode special characters in a plain-text string for display as HTML. * Encode special characters in a plain-text string for display as HTML.
* *
...@@ -825,9 +816,9 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO ...@@ -825,9 +816,9 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO
'link' => $link, 'link' => $link,
'user' => $user, 'user' => $user,
'request_uri' => $base_root . request_uri(), 'request_uri' => $base_root . request_uri(),
'referer' => referer_uri(), 'referer' => $_SERVER['HTTP_REFERER'],
'ip' => ip_address(), 'ip' => ip_address(),
'timestamp' => time(), 'timestamp' => $_SERVER['REQUEST_TIME'],
); );
// Call the logging hooks to log/process the message // Call the logging hooks to log/process the message
......
...@@ -17,7 +17,7 @@ function cache_get($cid, $table = 'cache') { ...@@ -17,7 +17,7 @@ function cache_get($cid, $table = 'cache') {
// Garbage collection necessary when enforcing a minimum cache lifetime // Garbage collection necessary when enforcing a minimum cache lifetime
$cache_flush = variable_get('cache_flush', 0); $cache_flush = variable_get('cache_flush', 0);
if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= time())) { if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= $_SERVER['REQUEST_TIME'])) {
// Reset the variable immediately to prevent a meltdown in heavy load situations. // Reset the variable immediately to prevent a meltdown in heavy load situations.
variable_set('cache_flush', 0); variable_set('cache_flush', 0);
// Time to flush old cache data // Time to flush old cache data
...@@ -101,7 +101,7 @@ function cache_get($cid, $table = 'cache') { ...@@ -101,7 +101,7 @@ function cache_get($cid, $table = 'cache') {
function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) { function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
$fields = array( $fields = array(
'serialized' => 0, 'serialized' => 0,
'created' => time(), 'created' => $_SERVER['REQUEST_TIME'],
'expire' => $expire, 'expire' => $expire,
'headers' => $headers, 'headers' => $headers,
); );
...@@ -152,23 +152,23 @@ function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) { ...@@ -152,23 +152,23 @@ function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
// will be saved into the sessions table by sess_write(). We then // will be saved into the sessions table by sess_write(). We then
// simulate that the cache was flushed for this user by not returning // simulate that the cache was flushed for this user by not returning
// cached data that was cached before the timestamp. // cached data that was cached before the timestamp.
$user->cache = time(); $user->cache = $_SERVER['REQUEST_TIME'];
$cache_flush = variable_get('cache_flush', 0); $cache_flush = variable_get('cache_flush', 0);
if ($cache_flush == 0) { if ($cache_flush == 0) {
// This is the first request to clear the cache, start a timer. // This is the first request to clear the cache, start a timer.
variable_set('cache_flush', time()); variable_set('cache_flush', $_SERVER['REQUEST_TIME']);
} }
else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) { else if ($_SERVER['REQUEST_TIME'] > ($cache_flush + variable_get('cache_lifetime', 0))) {
// Clear the cache for everyone, cache_flush_delay seconds have // Clear the cache for everyone, cache_flush_delay seconds have
// passed since the first request to clear the cache. // passed since the first request to clear the cache.
db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time()); db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, $_SERVER['REQUEST_TIME']);
variable_set('cache_flush', 0); variable_set('cache_flush', 0);
} }
} }
else { else {
// No minimum cache lifetime, flush all temporary cache entries now. // No minimum cache lifetime, flush all temporary cache entries now.
db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time()); db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, $_SERVER['REQUEST_TIME']);
} }
} }
else { else {
......
...@@ -873,7 +873,7 @@ function valid_url($url, $absolute = FALSE) { ...@@ -873,7 +873,7 @@ function valid_url($url, $absolute = FALSE) {
* The name of an event. * The name of an event.
*/ */
function flood_register_event($name) { function flood_register_event($name) {
db_query("INSERT INTO {flood} (event, hostname, timestamp) VALUES ('%s', '%s', %d)", $name, ip_address(), time()); db_query("INSERT INTO {flood} (event, hostname, timestamp) VALUES ('%s', '%s', %d)", $name, ip_address(), $_SERVER['REQUEST_TIME']);
} }
/** /**
...@@ -890,7 +890,7 @@ function flood_register_event($name) { ...@@ -890,7 +890,7 @@ function flood_register_event($name) {
* True if the user did not exceed the hourly threshold. False otherwise. * True if the user did not exceed the hourly threshold. False otherwise.
*/ */
function flood_is_allowed($name, $threshold) { function flood_is_allowed($name, $threshold) {
$number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), time() - 3600)); $number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), $_SERVER['REQUEST_TIME'] - 3600));
return ($number < $threshold ? TRUE : FALSE); return ($number < $threshold ? TRUE : FALSE);
} }
...@@ -2074,7 +2074,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) { ...@@ -2074,7 +2074,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
// browser-caching. The string changes on every update or full cache // browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the // flush, forcing browsers to load a new copy of the files, as the
// URL changed. Files that should not be cached (see drupal_add_js()) // URL changed. Files that should not be cached (see drupal_add_js())
// get time() as query-string instead, to enforce reload on every // get $_SERVER['REQUEST_TIME'] as query-string instead, to enforce reload on every
// page request. // page request.
$query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1); $query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1);
...@@ -2101,7 +2101,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) { ...@@ -2101,7 +2101,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
// Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones. // Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones.
foreach ($data as $path => $info) { foreach ($data as $path => $info) {
if (!$info['preprocess'] || !$is_writable || !$preprocess_js) { if (!$info['preprocess'] || !$is_writable || !$preprocess_js) {
$no_preprocess[$type] .= '<script type="text/javascript"' . ($info['defer'] ? ' defer="defer"' : '') . ' src="' . base_path() . $path . ($info['cache'] ? $query_string : '?' . time()) . "\"></script>\n"; $no_preprocess[$type] .= '<script type="text/javascript"' . ($info['defer'] ? ' defer="defer"' : '') . ' src="' . base_path() . $path . ($info['cache'] ? $query_string : '?' . $_SERVER['REQUEST_TIME']) . "\"></script>\n";
} }
else { else {
$files[$path] = $info; $files[$path] = $info;
...@@ -2553,7 +2553,7 @@ function drupal_cron_run() { ...@@ -2553,7 +2553,7 @@ function drupal_cron_run() {
$semaphore = variable_get('cron_semaphore', FALSE); $semaphore = variable_get('cron_semaphore', FALSE);
if ($semaphore) { if ($semaphore) {
if (time() - $semaphore > 3600) { if ($_SERVER['REQUEST_TIME'] - $semaphore > 3600) {
// Either cron has been running for more than an hour or the semaphore // Either cron has been running for more than an hour or the semaphore
// was not reset due to a database error. // was not reset due to a database error.
watchdog('cron', 'Cron has been running for more than an hour and is most likely stuck.', array(), WATCHDOG_ERROR); watchdog('cron', 'Cron has been running for more than an hour and is most likely stuck.', array(), WATCHDOG_ERROR);
...@@ -2571,13 +2571,13 @@ function drupal_cron_run() { ...@@ -2571,13 +2571,13 @@ function drupal_cron_run() {
register_shutdown_function('drupal_cron_cleanup'); register_shutdown_function('drupal_cron_cleanup');
// Lock cron semaphore // Lock cron semaphore
variable_set('cron_semaphore', time()); variable_set('cron_semaphore', $_SERVER['REQUEST_TIME']);
// Iterate through the modules calling their cron handlers (if any): // Iterate through the modules calling their cron handlers (if any):
module_invoke_all('cron'); module_invoke_all('cron');
// Record cron time // Record cron time
variable_set('cron_last', time()); variable_set('cron_last', $_SERVER['REQUEST_TIME']);
watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE); watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
// Release cron semaphore // Release cron semaphore
......
...@@ -613,7 +613,7 @@ function file_save_upload($source, $validators = array(), $dest = FALSE, $replac ...@@ -613,7 +613,7 @@ function file_save_upload($source, $validators = array(), $dest = FALSE, $replac
// If we made it this far it's safe to record this file in the database. // If we made it this far it's safe to record this file in the database.
$file->uid = $user->uid; $file->uid = $user->uid;
$file->status = FILE_STATUS_TEMPORARY; $file->status = FILE_STATUS_TEMPORARY;
$file->timestamp = time(); $file->timestamp = $_SERVER['REQUEST_TIME'];
drupal_write_record('files', $file); drupal_write_record('files', $file);
// Add file to the cache. // Add file to the cache.
......
...@@ -235,9 +235,9 @@ function form_set_cache($form_build_id, $form, $form_state) { ...@@ -235,9 +235,9 @@ function form_set_cache($form_build_id, $form, $form_state) {
// 6 hours cache life time for forms should be plenty. // 6 hours cache life time for forms should be plenty.
$expire = 21600; $expire = 21600;
cache_set('form_' . $form_build_id, $form, 'cache_form', time() + $expire); cache_set('form_' . $form_build_id, $form, 'cache_form', $_SERVER['REQUEST_TIME'] + $expire);
if (!empty($form_state['storage'])) { if (!empty($form_state['storage'])) {
cache_set('storage_' . $form_build_id, $form_state['storage'], 'cache_form', time() + $expire); cache_set('storage_' . $form_build_id, $form_state['storage'], 'cache_form', $_SERVER['REQUEST_TIME'] + $expire);
} }
} }
...@@ -1645,9 +1645,9 @@ function theme_date($element) { ...@@ -1645,9 +1645,9 @@ function theme_date($element) {
function form_process_date($element) { function form_process_date($element) {
// Default to current date // Default to current date
if (empty($element['#value'])) { if (empty($element['#value'])) {
$element['#value'] = array('day' => format_date(time(), 'custom', 'j'), $element['#value'] = array('day' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'j'),
'month' => format_date(time(), 'custom', 'n'), 'month' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'n'),
'year' => format_date(time(), 'custom', 'Y')); 'year' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'Y'));
} }
$element['#tree'] = TRUE; $element['#tree'] = TRUE;
...@@ -2483,7 +2483,7 @@ function batch_process($redirect = NULL, $url = NULL) { ...@@ -2483,7 +2483,7 @@ function batch_process($redirect = NULL, $url = NULL) {
// Initiate db storage in order to get a batch id. We have to provide // Initiate db storage in order to get a batch id. We have to provide
// at least an empty string for the (not null) 'token' column. // at least an empty string for the (not null) 'token' column.
db_query("INSERT INTO {batch} (token, timestamp) VALUES ('', %d)", time()); db_query("INSERT INTO {batch} (token, timestamp) VALUES ('', %d)", $_SERVER['REQUEST_TIME']);
$batch['id'] = db_last_insert_id('batch', 'bid'); $batch['id'] = db_last_insert_id('batch', 'bid');
// Now that we have a batch id, we can generate the redirection link in // Now that we have a batch id, we can generate the redirection link in
......
...@@ -73,17 +73,17 @@ function sess_write($key, $value) { ...@@ -73,17 +73,17 @@ function sess_write($key, $value) {
// and gives more useful statistics. We can't eliminate anonymous session // and gives more useful statistics. We can't eliminate anonymous session
// table rows without breaking "Who's Online" block. // table rows without breaking "Who's Online" block.
if ($user->uid || $value || count($_COOKIE)) { if ($user->uid || $value || count($_COOKIE)) {
db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, time()); db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, $_SERVER['REQUEST_TIME']);
} }
} }
else { else {
db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, time(), $key); db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, $_SERVER['REQUEST_TIME'], $key);
if (db_affected_rows()) { if (db_affected_rows()) {
// Last access time is updated no more frequently than once every 180 seconds. // Last access time is updated no more frequently than once every 180 seconds.
// This reduces contention in the users table. // This reduces contention in the users table.
if ($user->uid && time() - $user->access > variable_get('session_write_interval', 180)) { if ($user->uid && $_SERVER['REQUEST_TIME'] - $user->access > variable_get('session_write_interval', 180)) {
db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid); db_query("UPDATE {users} SET access = %d WHERE uid = %d", $_SERVER['REQUEST_TIME'], $user->uid);
} }
} }
} }
...@@ -143,7 +143,7 @@ function sess_gc($lifetime) { ...@@ -143,7 +143,7 @@ function sess_gc($lifetime) {
// for three weeks before deleting them, you need to set gc_maxlifetime // for three weeks before deleting them, you need to set gc_maxlifetime
// to '1814400'. At that value, only after a user doesn't log in after // to '1814400'. At that value, only after a user doesn't log in after
// three weeks (1814400 seconds) will his/her session be removed. // three weeks (1814400 seconds) will his/her session be removed.
db_query("DELETE FROM {sessions} WHERE timestamp < %d", time() - $lifetime); db_query("DELETE FROM {sessions} WHERE timestamp < %d", $_SERVER['REQUEST_TIME'] - $lifetime);
return TRUE; return TRUE;
} }
......
...@@ -1174,7 +1174,7 @@ function install_configure_form_submit($form, &$form_state) { ...@@ -1174,7 +1174,7 @@ function install_configure_form_submit($form, &$form_state) {
$user->sid = session_id(); $user->sid = session_id();
// Record when this install ran. // Record when this install ran.
variable_set('install_time', time()); variable_set('install_time', $_SERVER['REQUEST_TIME']);
} }
// Start the installer. // Start the installer.
......
...@@ -27,7 +27,7 @@ function aggregator_view() { ...@@ -27,7 +27,7 @@ function aggregator_view() {
$header = array(t('Title'), t('Items'), t('Last update'), t('Next update'), array('data' => t('Operations'), 'colspan' => '3')); $header = array(t('Title'), t('Items'), t('Last update'), t('Next update'), array('data' => t('Operations'), 'colspan' => '3'));
$rows = array(); $rows = array();
while ($feed = db_fetch_object($result)) { while ($feed = db_fetch_object($result)) {
$rows[] = array(l($feed->title, "aggregator/sources/$feed->fid"), format_plural($feed->items, '1 item', '@count items'), ($feed->checked ? t('@time ago', array('@time' => format_interval(time() - $feed->checked))) : t('never')), ($feed->checked ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - time()))) : t('never')), l(t('edit'), "admin/content/aggregator/edit/feed/$feed->fid"), l(t('remove items'), "admin/content/aggregator/remove/$feed->fid"), l(t('update items'), "admin/content/aggregator/update/$feed->fid")); $rows[] = array(l($feed->title, "aggregator/sources/$feed->fid"), format_plural($feed->items, '1 item', '@count items'), ($feed->checked ? t('@time ago', array('@time' => format_interval($_SERVER['REQUEST_TIME'] - $feed->checked))) : t('never')), ($feed->checked ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - $_SERVER['REQUEST_TIME']))) : t('never')), l(t('edit'), "admin/content/aggregator/edit/feed/$feed->fid"), l(t('remove items'), "admin/content/aggregator/remove/$feed->fid"), l(t('update items'), "admin/content/aggregator/update/$feed->fid"));
} }
$output .= theme('table', $header, $rows); $output .= theme('table', $header, $rows);
......
...@@ -281,7 +281,7 @@ function aggregator_perm() { ...@@ -281,7 +281,7 @@ function aggregator_perm() {
* Checks news feeds for updates once their refresh interval has elapsed. * Checks news feeds for updates once their refresh interval has elapsed.
*/ */
function aggregator_cron() { function aggregator_cron() {
$result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', time()); $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', $_SERVER['REQUEST_TIME']);
while ($feed = db_fetch_array($result)) { while ($feed = db_fetch_array($result)) {
aggregator_refresh($feed); aggregator_refresh($feed);
} }
...@@ -592,7 +592,7 @@ function aggregator_refresh($feed) { ...@@ -592,7 +592,7 @@ function aggregator_refresh($feed) {
// Process HTTP response code. // Process HTTP response code.
switch ($result->code) { switch ($result->code) {
case 304: case 304:
db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', time(), $feed['fid']); db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', $_SERVER['REQUEST_TIME'], $feed['fid']);
drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title']))); drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title'])));
break; break;
case 301: case 301:
...@@ -606,7 +606,7 @@ function aggregator_refresh($feed) { ...@@ -606,7 +606,7 @@ function aggregator_refresh($feed) {
// data. If both are equal we say that feed is not updated. // data. If both are equal we say that feed is not updated.
$md5 = md5($result->data); $md5 = md5($result->data);
if ($feed['hash'] == $md5) { if ($feed['hash'] == $md5) {
db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', time(), $feed['fid']); db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', $_SERVER['REQUEST_TIME'], $feed['fid']);
drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title']))); drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title'])));
break; break;
} }
...@@ -636,7 +636,7 @@ function aggregator_refresh($feed) { ...@@ -636,7 +636,7 @@ function aggregator_refresh($feed) {
$etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag']; $etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag'];
// Update the feed data. // Update the feed data.
db_query("UPDATE {aggregator_feed} SET url = '%s', checked = %d, link = '%s', description = '%s', image = '%s', hash = '%s', etag = '%s', modified = %d WHERE fid = %d", $feed['url'], time(), $channel['LINK'], $channel['DESCRIPTION'], $image, $md5, $etag, $modified, $feed['fid']); db_query("UPDATE {aggregator_feed} SET url = '%s', checked = %d, link = '%s', description = '%s', image = '%s', hash = '%s', etag = '%s', modified = %d WHERE fid = %d", $feed['url'], $_SERVER['REQUEST_TIME'], $channel['LINK'], $channel['DESCRIPTION'], $image, $md5, $etag, $modified, $feed['fid']);
// Clear the cache. // Clear the cache.
cache_clear_all(); cache_clear_all();
...@@ -803,14 +803,14 @@ function aggregator_parse_feed(&$data, $feed) { ...@@ -803,14 +803,14 @@ function aggregator_parse_feed(&$data, $feed) {
} }
if (!$timestamp) { if (!$timestamp) {
$timestamp = isset($entry->timestamp) ? $entry->timestamp : time(); $timestamp = isset($entry->timestamp) ? $entry->timestamp : $_SERVER['REQUEST_TIME'];
} }
$item += array('AUTHOR' => '', 'DESCRIPTION' => ''); $item += array('AUTHOR' => '', 'DESCRIPTION' => '');
aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid : ''), 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION'], 'guid' => $guid)); aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid : ''), 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION'], 'guid' => $guid));
} }
// Remove all items that are older than flush item timer. // Remove all items that are older than flush item timer.
$age = time() - variable_get('aggregator_clear', 9676800); $age = $_SERVER['REQUEST_TIME'] - variable_get('aggregator_clear', 9676800);
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age); $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
$items = array(); $items = array();
......
...@@ -265,7 +265,7 @@ function template_preprocess_aggregator_item(&$variables) { ...@@ -265,7 +265,7 @@ function template_preprocess_aggregator_item(&$variables) {
$variables['source_title'] = check_plain($item->ftitle); $variables['source_title'] = check_plain($item->ftitle);
} }
if (date('Ymd', $item->timestamp) == date('Ymd')) { if (date('Ymd', $item->timestamp) == date('Ymd')) {
$variables['source_date'] = t('%ago ago', array('%ago' => format_interval(time() - $item->timestamp))); $variables['source_date'] = t('%ago ago', array('%ago' => format_interval($_SERVER['REQUEST_TIME'] - $item->timestamp)));
} }
else { else {
$variables['source_date'] = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i')); $variables['source_date'] = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));
...@@ -462,7 +462,7 @@ function template_preprocess_aggregator_summary_item(&$variables) { ...@@ -462,7 +462,7 @@ function template_preprocess_aggregator_summary_item(&$variables) {
$variables['feed_url'] = check_url($item->link); $variables['feed_url'] = check_url($item->link);
$variables['feed_title'] = check_plain($item->title); $variables['feed_title'] = check_plain($item->title);
$variables['feed_age'] = t('%age old', array('%age' => format_interval(time() - $item->timestamp))); $variables['feed_age'] = t('%age old', array('%age' => format_interval($_SERVER['REQUEST_TIME'] - $item->timestamp)));
$variables['source_url'] = ''; $variables['source_url'] = '';
$variables['source_title'] = ''; $variables['source_title'] = '';
...@@ -486,7 +486,7 @@ function template_preprocess_aggregator_feed_source(&$variables) { ...@@ -486,7 +486,7 @@ function template_preprocess_aggregator_feed_source(&$variables) {
$variables['source_url'] = check_url(url($feed->link, array('absolute' => TRUE))); $variables['source_url'] = check_url(url($feed->link, array('absolute' => TRUE)));
if ($feed->checked) { if ($feed->checked) {
$variables['last_checked'] = t('@time ago', array('@time' => format_interval(time() - $feed->checked))); $variables['last_checked'] = t('@time ago', array('@time' => format_interval($_SERVER['REQUEST_TIME'] - $feed->checked)));
} }
else { else {
$variables['last_checked'] = t('never'); $variables['last_checked'] = t('never');
......
...@@ -218,7 +218,7 @@ function blogapi_blogger_new_post($appkey, $blogid, $username, $password, $conte ...@@ -218,7 +218,7 @@ function blogapi_blogger_new_post($appkey, $blogid, $username, $password, $conte
} }
if (user_access('administer nodes') && !isset($edit['date'])) { if (user_access('administer nodes') && !isset($edit['date'])) {
$edit['date'] = format_date(time(), 'custom', 'Y-m-d H:i:s O'); $edit['date'] = format_date($_SERVER['REQUEST_TIME'], 'custom', 'Y-m-d H:i:s O');
} }
node_invoke_nodeapi($edit, 'blogapi new'); node_invoke_nodeapi($edit, 'blogapi new');
......
...@@ -14,11 +14,11 @@ function comment_enable() { ...@@ -14,11 +14,11 @@ function comment_enable() {
*/ */
function comment_update_1() { function comment_update_1() {
// Change any future last comment timestamps to current time. // Change any future last comment timestamps to current time.
db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', time(), time()); db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME']);
// Unstuck node indexing timestamp if needed. // Unstuck node indexing timestamp if needed.
if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) { if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) {
variable_set('node_cron_last', min(time(), $last)); variable_set('node_cron_last', min($_SERVER['REQUEST_TIME'], $last));
} }
return array(); return array();
......
...@@ -378,7 +378,7 @@ function theme_comment_block() { ...@@ -378,7 +378,7 @@ function theme_comment_block() {
$items = array(); $items = array();
$number = variable_get('comment_block_count', 10); $number = variable_get('comment_block_count', 10);
foreach (comment_get_recent($number) as $comment) { foreach (comment_get_recent($number) as $comment) {
$items[] = l($comment->subject, 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)) . '<br />' . t('@time ago', array('@time' => format_interval(time() - $comment->timestamp))); $items[] = l($comment->subject, 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)) . '<br />' . t('@time ago', array('@time' => format_interval($_SERVER['REQUEST_TIME'] - $comment->timestamp)));
} }
if ($items) { if ($items) {
...@@ -712,7 +712,7 @@ function comment_save($edit) { ...@@ -712,7 +712,7 @@ function comment_save($edit) {
} }
if (empty($edit['timestamp'])) { if (empty($edit['timestamp'])) {
$edit['timestamp'] = time(); $edit['timestamp'] = $_SERVER['REQUEST_TIME'];
} }
if ($edit['uid'] === $user->uid) { // '===' Need to modify anonymous users as well. if ($edit['uid'] === $user->uid) { // '===' Need to modify anonymous users as well.
...@@ -1448,7 +1448,7 @@ function comment_form_add_preview($form, &$form_state) { ...@@ -1448,7 +1448,7 @@ function comment_form_add_preview($form, &$form_state) {
$comment->name = variable_get('anonymous', t('Anonymous')); $comment->name = variable_get('anonymous', t('Anonymous'));
} }
$comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : time(); $comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : $_SERVER['REQUEST_TIME'];
$output .= theme('comment_view', $comment, $node); $output .= theme('comment_view', $comment, $node);
} }
...@@ -1490,7 +1490,7 @@ function comment_form_validate($form, &$form_state) { ...@@ -1490,7 +1490,7 @@ function comment_form_validate($form, &$form_state) {
foreach (array('name', 'homepage', 'mail') as $field) { foreach (array('name', 'homepage', 'mail') as $field) {
// Set cookie for 365 days. // Set cookie for 365 days.
if (isset($form_state['values'][$field])) { if (isset($form_state['values'][$field])) {
setcookie('comment_info_' . $field, $form_state['values'][$field], time() + 31536000, '/'); setcookie('comment_info_' . $field, $form_state['values'][$field], $_SERVER['REQUEST_TIME'] + 31536000, '/');
} }
} }
} }
......
...@@ -102,9 +102,9 @@ class DBLogTestCase extends DrupalWebTestCase { ...@@ -102,9 +102,9 @@ class DBLogTestCase extends DrupalWebTestCase {
'link' => NULL, 'link' => NULL,
'user' => $this->big_user, 'user' => $this->big_user,
'request_uri' => $base_root . request_uri(), 'request_uri' => $base_root . request_uri(),
'referer' => referer_uri(), 'referer' => $_SERVER['HTTP_REFERER'],
'ip' => ip_address(), 'ip' => ip_address(),
'timestamp' => time(), 'timestamp' => $_SERVER['REQUEST_TIME'],
); );
$message = 'Log entry added to test the dblog row limit.'; $message = 'Log entry added to test the dblog row limit.';
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
......
...@@ -446,7 +446,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) { ...@@ -446,7 +446,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
// Store in cache with a minimum expiration time of 1 day. // Store in cache with a minimum expiration time of 1 day.
if ($cache) { if ($cache) {
cache_set($cache_id, $text, 'cache_filter', time() + (60 * 60 * 24)); cache_set($cache_id, $text, 'cache_filter', $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));
} }
} }
else { else {
......
...@@ -908,7 +908,7 @@ function template_preprocess_forum_topic_navigation(&$variables) { ...@@ -908,7 +908,7 @@ function template_preprocess_forum_topic_navigation(&$variables) {
*/ */
function template_preprocess_forum_submitted(&$variables) { function template_preprocess_forum_submitted(&$variables) {
$variables['author'] = isset($variables['topic']->uid) ? theme('username', $variables['topic']) : ''; $variables['author'] = isset($variables['topic']->uid) ? theme('username', $variables['topic']) : '';
$variables['time'] = isset($variables['topic']->timestamp) ? format_interval(time() - $variables['topic']->timestamp) : ''; $variables['time'] = isset($variables['topic']->timestamp) ? format_interval($_SERVER['REQUEST_TIME'] - $variables['topic']->timestamp) : '';
} }
function _forum_user_last_visit($nid) { function _forum_user_last_visit($nid) {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Nodes changed after this time may be marked new, updated, or read, depending * Nodes changed after this time may be marked new, updated, or read, depending
* on their state for the current user. Defaults to 30 days ago. * on their state for the current user. Defaults to 30 days ago.
*/