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') {
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.
*
......@@ -825,9 +816,9 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO
'link' => $link,
'user' => $user,
'request_uri' => $base_root . request_uri(),
'referer' => referer_uri(),
'referer' => $_SERVER['HTTP_REFERER'],
'ip' => ip_address(),
'timestamp' => time(),
'timestamp' => $_SERVER['REQUEST_TIME'],
);
// Call the logging hooks to log/process the message
......
......@@ -17,7 +17,7 @@ function cache_get($cid, $table = 'cache') {
// Garbage collection necessary when enforcing a minimum cache lifetime
$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.
variable_set('cache_flush', 0);
// Time to flush old cache data
......@@ -101,7 +101,7 @@ function cache_get($cid, $table = 'cache') {
function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
$fields = array(
'serialized' => 0,
'created' => time(),
'created' => $_SERVER['REQUEST_TIME'],
'expire' => $expire,
'headers' => $headers,
);
......@@ -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
// simulate that the cache was flushed for this user by not returning
// cached data that was cached before the timestamp.
$user->cache = time();
$user->cache = $_SERVER['REQUEST_TIME'];
$cache_flush = variable_get('cache_flush', 0);
if ($cache_flush == 0) {
// 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
// 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);
}
}
else {
// 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 {
......
......@@ -873,7 +873,7 @@ function valid_url($url, $absolute = FALSE) {
* The name of an event.
*/
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) {
* True if the user did not exceed the hourly threshold. False otherwise.
*/
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);
}
......@@ -2074,7 +2074,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) {
// browser-caching. The string changes on every update or full cache
// 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())
// 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.
$query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1);
......@@ -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.
foreach ($data as $path => $info) {
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 {
$files[$path] = $info;
......@@ -2553,7 +2553,7 @@ function drupal_cron_run() {
$semaphore = variable_get('cron_semaphore', FALSE);
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
// 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);
......@@ -2571,13 +2571,13 @@ function drupal_cron_run() {
register_shutdown_function('drupal_cron_cleanup');
// 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):
module_invoke_all('cron');
// Record cron time
variable_set('cron_last', time());
variable_set('cron_last', $_SERVER['REQUEST_TIME']);
watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
// Release cron semaphore
......
......@@ -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.
$file->uid = $user->uid;
$file->status = FILE_STATUS_TEMPORARY;
$file->timestamp = time();
$file->timestamp = $_SERVER['REQUEST_TIME'];
drupal_write_record('files', $file);
// Add file to the cache.
......
......@@ -235,9 +235,9 @@ function form_set_cache($form_build_id, $form, $form_state) {
// 6 hours cache life time for forms should be plenty.
$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'])) {
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) {
function form_process_date($element) {
// Default to current date
if (empty($element['#value'])) {
$element['#value'] = array('day' => format_date(time(), 'custom', 'j'),
'month' => format_date(time(), 'custom', 'n'),
'year' => format_date(time(), 'custom', 'Y'));
$element['#value'] = array('day' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'j'),
'month' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'n'),
'year' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'Y'));
}
$element['#tree'] = TRUE;
......@@ -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
// 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');
// Now that we have a batch id, we can generate the redirection link in
......
......@@ -73,17 +73,17 @@ function sess_write($key, $value) {
// and gives more useful statistics. We can't eliminate anonymous session
// table rows without breaking "Who's Online" block.
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 {
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()) {
// Last access time is updated no more frequently than once every 180 seconds.
// This reduces contention in the users table.
if ($user->uid && time() - $user->access > variable_get('session_write_interval', 180)) {
db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid);
if ($user->uid && $_SERVER['REQUEST_TIME'] - $user->access > variable_get('session_write_interval', 180)) {
db_query("UPDATE {users} SET access = %d WHERE uid = %d", $_SERVER['REQUEST_TIME'], $user->uid);
}
}
}
......@@ -143,7 +143,7 @@ function sess_gc($lifetime) {
// 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
// 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;
}
......
......@@ -1174,7 +1174,7 @@ function install_configure_form_submit($form, &$form_state) {
$user->sid = session_id();
// Record when this install ran.
variable_set('install_time', time());
variable_set('install_time', $_SERVER['REQUEST_TIME']);
}
// Start the installer.
......
......@@ -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'));
$rows = array();
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);
......
......@@ -281,7 +281,7 @@ function aggregator_perm() {
* Checks news feeds for updates once their refresh interval has elapsed.
*/
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)) {
aggregator_refresh($feed);
}
......@@ -592,7 +592,7 @@ function aggregator_refresh($feed) {
// Process HTTP response code.
switch ($result->code) {
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'])));
break;
case 301:
......@@ -606,7 +606,7 @@ function aggregator_refresh($feed) {
// data. If both are equal we say that feed is not updated.
$md5 = md5($result->data);
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'])));
break;
}
......@@ -636,7 +636,7 @@ function aggregator_refresh($feed) {
$etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag'];
// 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.
cache_clear_all();
......@@ -803,14 +803,14 @@ function aggregator_parse_feed(&$data, $feed) {
}
if (!$timestamp) {
$timestamp = isset($entry->timestamp) ? $entry->timestamp : time();
$timestamp = isset($entry->timestamp) ? $entry->timestamp : $_SERVER['REQUEST_TIME'];
}
$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));
}
// 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);
$items = array();
......
......@@ -265,7 +265,7 @@ function template_preprocess_aggregator_item(&$variables) {
$variables['source_title'] = check_plain($item->ftitle);
}
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 {
$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) {
$variables['feed_url'] = check_url($item->link);
$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_title'] = '';
......@@ -486,7 +486,7 @@ function template_preprocess_aggregator_feed_source(&$variables) {
$variables['source_url'] = check_url(url($feed->link, array('absolute' => TRUE)));
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 {
$variables['last_checked'] = t('never');
......
......@@ -218,7 +218,7 @@ function blogapi_blogger_new_post($appkey, $blogid, $username, $password, $conte
}
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');
......
......@@ -14,11 +14,11 @@ function comment_enable() {
*/
function comment_update_1() {
// 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.
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();
......
......@@ -378,7 +378,7 @@ function theme_comment_block() {
$items = array();
$number = variable_get('comment_block_count', 10);
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) {
......@@ -712,7 +712,7 @@ function comment_save($edit) {
}
if (empty($edit['timestamp'])) {
$edit['timestamp'] = time();
$edit['timestamp'] = $_SERVER['REQUEST_TIME'];
}
if ($edit['uid'] === $user->uid) { // '===' Need to modify anonymous users as well.
......@@ -1448,7 +1448,7 @@ function comment_form_add_preview($form, &$form_state) {
$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);
}
......@@ -1490,7 +1490,7 @@ function comment_form_validate($form, &$form_state) {
foreach (array('name', 'homepage', 'mail') as $field) {
// Set cookie for 365 days.
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 {
'link' => NULL,
'user' => $this->big_user,
'request_uri' => $base_root . request_uri(),
'referer' => referer_uri(),
'referer' => $_SERVER['HTTP_REFERER'],
'ip' => ip_address(),
'timestamp' => time(),
'timestamp' => $_SERVER['REQUEST_TIME'],
);
$message = 'Log entry added to test the dblog row limit.';
for ($i = 0; $i < $count; $i++) {
......
......@@ -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.
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 {
......
......@@ -908,7 +908,7 @@ function template_preprocess_forum_topic_navigation(&$variables) {
*/
function template_preprocess_forum_submitted(&$variables) {
$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) {
......
......@@ -13,7 +13,7 @@
* 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.
*/
define('NODE_NEW_LIMIT', time() - 30 * 24 * 60 * 60);
define('NODE_NEW_LIMIT', $_SERVER['REQUEST_TIME'] - 30 * 24 * 60 * 60);
/**
* Node is being built before being viewed normally.
......@@ -188,10 +188,10 @@ function node_tag_new($nid) {
if ($user->uid) {
if (node_last_viewed($nid)) {
db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', time(), $user->uid, $nid);
db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', $_SERVER['REQUEST_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, $_SERVER['REQUEST_TIME']);
}
}
}
......@@ -880,7 +880,7 @@ function node_submit($node) {
$node->uid = 0;
}
}
$node->created = !empty($node->date) ? strtotime($node->date) : time();
$node->created = !empty($node->date) ? strtotime($node->date) : $_SERVER['REQUEST_TIME'];
$node->validated = TRUE;
return $node;
......@@ -932,12 +932,12 @@ function node_save(&$node) {
// Set some required fields:
if (empty($node->created)) {
$node->created = time();
$node->created = $_SERVER['REQUEST_TIME'];
}
// The changed timestamp is always updated for bookkeeping purposes (revisions, searching, ...)
$node->changed = time();
$node->changed = $_SERVER['REQUEST_TIME'];
$node->timestamp = time();
$node->timestamp = $_SERVER['REQUEST_TIME'];
$node->format = isset($node->format) ? $node->format : FILTER_FORMAT_DEFAULT;
$update_node = TRUE;
......@@ -1221,7 +1221,7 @@ function node_search($op = 'search', $keys = NULL) {
return t('Content');
case 'reset':
db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", time());
db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", $_SERVER['REQUEST_TIME']);
return;
case 'status':
......
......@@ -80,7 +80,7 @@ function node_object_prepare(&$node) {
}
global $user;
$node->uid = $user->uid;
$node->created = time();
$node->created = $_SERVER['REQUEST_TIME'];
}
else {
$node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
......@@ -361,7 +361,7 @@ function node_preview($node) {
$node->picture = $user->picture;
}
$node->changed = time();
$node->changed = $_SERVER['REQUEST_TIME'];
// Extract a teaser, if it hasn't been set (e.g. by a module-provided
// 'teaser' form item).
......
......@@ -333,7 +333,7 @@ function openid_association($op_endpoint) {
module_load_include('inc', 'openid');
// Remove Old Associations:
db_query("DELETE FROM {openid_association} WHERE created + expires_in < %d", time());
db_query("DELETE FROM {openid_association} WHERE created + expires_in < %d", $_SERVER['REQUEST_TIME']);
// Check to see if we have an association for this IdP already
$assoc_handle = db_result(db_query("SELECT assoc_handle FROM {openid_association} WHERE idp_endpoint_uri = '%s'", $op_endpoint));
......@@ -367,7 +367,7 @@ function openid_association($op_endpoint) {
$assoc_response['mac_key'] = base64_encode(_openid_dh_xorsecret($shared, $enc_mac_key));
}
db_query("INSERT INTO {openid_association} (idp_endpoint_uri, session_type, assoc_handle, assoc_type, expires_in, mac_key, created) VALUES('%s', '%s', '%s', '%s', %d, '%s', %d)",
$op_endpoint, $assoc_response['session_type'], $assoc_response['assoc_handle'], $assoc_response['assoc_type'], $assoc_response['expires_in'], $assoc_response['mac_key'], time());
$op_endpoint, $assoc_response['session_type'], $assoc_response['assoc_handle'], $assoc_response['assoc_type'], $assoc_response['expires_in'], $assoc_response['mac_key'], $_SERVER['REQUEST_TIME']);
$assoc_handle = $assoc_response['assoc_handle'];
}
......
......@@ -161,7 +161,7 @@ function poll_block($op = 'list', $delta = '') {
* Closes polls that have exceeded their allowed runtime.
*/
function poll_cron() {
$result = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < ' . time() . ' AND p.active = 1 AND p.runtime != 0');
$result = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < ' . $_SERVER['REQUEST_TIME'] . ' AND p.active = 1 AND p.runtime != 0');
while ($poll = db_fetch_object($result)) {
db_query("UPDATE {poll} SET active = 0 WHERE nid = %d", $poll->nid);
}
......
......@@ -622,7 +622,7 @@ function search_index($sid, $type, $text) {
* The nid of the node that needs reindexing.
*/
function search_touch_node($nid) {
db_query("UPDATE {search_dataset} SET reindex = %d WHERE sid = %d AND type = 'node'", time(), $nid);
db_query("UPDATE {search_dataset} SET reindex = %d WHERE sid = %d AND type = 'node'", $_SERVER['REQUEST_TIME'], $nid);
}
/**
......
......@@ -236,7 +236,7 @@ class SearchRankingTestCase extends DrupalWebTestCase {
$settings['body'] .= " really rocks";
break;
case 'recent':
$settings['created'] = time() + 3600;
$settings['created'] = $_SERVER['REQUEST_TIME'] + 3600;
break;
case 'comments':
$settings['comment'] = 2;
......
......@@ -331,7 +331,7 @@ function drupalCreateNode($settings = array()) {
'body' => $this->randomName(32),
'title' => $this->randomName(8),
'comment' => 2,
'changed' => time(),
'changed' => $_SERVER['REQUEST_TIME'],
'format' => FILTER_FORMAT_DEFAULT,
'moderate' => 0,
'promote' => 0,
......
......@@ -113,7 +113,7 @@ class SessionTestCase extends DrupalWebTestCase {
$this->assertEqual($authenticated, $this->session_count_authenticated, t('Correctly counted @count authenticated sessions.', array('@count' => $authenticated)), t('Session'));
// Should return 0 sessions from 1 second from now.
$this->assertEqual(sess_count(time() + 1), 0, t('Correctly returned 0 sessions newer than the current time.'), t('Session'));
$this->assertEqual(sess_count($_SERVER['REQUEST_TIME'] + 1), 0, t('Correctly returned 0 sessions newer than the current time.'), t('Session'));
}
......
......@@ -66,7 +66,7 @@ class XMLRPCValidator1IncTestCase extends DrupalWebTestCase {
$bool_5 = (($int_5 % 2) == 0);
$string_5 = $this->randomName();
$double_5 = (double)(mt_rand(-1000,1000) / 100);
$time_5 = time();
$time_5 = $_SERVER['REQUEST_TIME'];
$base64_5 = $this->randomName(100);
$l_res_5 = xmlrpc_test_manyTypesTest($int_5, $bool_5, $string_5, $double_5, xmlrpc_date($time_5), $base64_5);
$l_res_5[5] = $l_res_5[5]->data; /* override warpping */
......
......@@ -122,7 +122,7 @@ function statistics_top_referrers() {
$rows = array();
while ($referrer = db_fetch_object($result)) {
$rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(time() - $referrer->last))));
$rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval($_SERVER['REQUEST_TIME'] - $referrer->last))));
}
if (empty($rows)) {
......
......@@ -55,7 +55,7 @@ function statistics_exit() {
'daycount' => 1,
'totalcount' => 1,
'nid' => arg(1),
'timestamp' => time(),
'timestamp' => $_SERVER['REQUEST_TIME'],
);
db_merge('node_counter')
->fields($fields)
......@@ -69,12 +69,12 @@ function statistics_exit() {
db_insert('accesslog')->fields(array(
'title' => strip_tags(drupal_get_title()),
'path' => $_GET['q'],
'url' => referer_uri(),
'url' => $_SERVER['HTTP_REFERER'],
'hostname' => ip_address(),
'uid' => $user->uid,
'sid' => session_id(),
'timer' => timer_read('page'),
'timestamp' => time(),
'timestamp' => $_SERVER['REQUEST_TIME'],
))->execute();
}
}
......@@ -188,14 +188,14 @@ function statistics_user($op, &$edit, &$user) {
function statistics_cron() {
$statistics_timestamp = variable_get('statistics_day_timestamp', '');
if ((time() - $statistics_timestamp) >= 86400) {
if (($_SERVER['REQUEST_TIME'] - $statistics_timestamp) >= 86400) {
// Reset day counts.
db_query('UPDATE {node_counter} SET daycount = 0');
variable_set('statistics_day_timestamp', time());
variable_set('statistics_day_timestamp', $_SERVER['REQUEST_TIME']);
}
// Clean up expired access logs.
db_query('DELETE FROM {accesslog} WHERE timestamp < %d', time() - variable_get('statistics_flush_accesslog_timer', 259200));
db_query('DELETE FROM {accesslog} WHERE timestamp < %d', $_SERVER['REQUEST_TIME'] - variable_get('statistics_flush_accesslog_timer', 259200));
}
/**
......
......@@ -23,7 +23,7 @@ class StatisticsBlockVisitorsTestCase extends DrupalWebTestCase {
$this->blocking_user = $this->drupalCreateUser(array('block IP addresses', 'access statistics'));
// Insert dummy access by anonymous user into access log.
db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, '%s', %d, %d)", 'test', 'node/1', 'http://example.com', '192.168.1.1', '0', '10', '10', time());
db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, '%s', %d, %d)", 'test', 'node/1', 'http://example.com', '192.168.1.1', '0', '10', '10', $_SERVER['REQUEST_TIME']);
}
/**
......
......@@ -1557,13 +1557,13 @@ function system_date_time_settings() {
// Date settings: construct choices for user
foreach ($date_short as $f) {
$date_short_choices[$f] = format_date(time(), 'custom', $f);
$date_short_choices[$f] = format_date($_SERVER['REQUEST_TIME'], 'custom', $f);
}
foreach ($date_medium as $f) {
$date_medium_choices[$f] = format_date(time(), 'custom', $f);
$date_medium_choices[$f] = format_date($_SERVER['REQUEST_TIME'], 'custom', $f);
}
foreach ($date_long as $f) {
$date_long_choices[$f] = format_date(time(), 'custom', $f);
$date_long_choices[$f] = format_date($_SERVER['REQUEST_TIME'], 'custom', $f);
}
$date_long_choices['custom'] = $date_medium_choices['custom'] = $date_short_choices['custom'] = t('Custom format');
......@@ -1622,7 +1622,7 @@ function system_date_time_settings() {
'#title' => t('Custom short date format'),
'#attributes' => array('class' => 'custom-format'),
'#default_value' => $default_short_custom,
'#description' => t('A user-defined short date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_short_custom))),
'#description' => t('A user-defined short date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date($_SERVER['REQUEST_TIME'], 'custom', $default_short_custom))),
);
$date_format_medium = variable_get('date_format_medium', $date_medium[1]);
......@@ -1645,7 +1645,7 @@ function system_date_time_settings() {
'#title' => t('Custom medium date format'),
'#attributes' => array('class' => 'custom-format'),
'#default_value' => $default_medium_custom,
'#description' => t('A user-defined medium date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_medium_custom))),
'#description' => t('A user-defined medium date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date($_SERVER['REQUEST_TIME'], 'custom', $default_medium_custom))),
);
$date_format_long = variable_get('date_format_long', $date_long[0]);
......@@ -1668,7 +1668,7 @@ function system_date_time_settings() {
'#title' => t('Custom long date format'),
'#attributes' => array('class' => 'custom-format'),
'#default_value' => $default_long_custom,
'#description' => t('A user-defined long date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_long_custom))),
'#description' => t('A user-defined long date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date($_SERVER['REQUEST_TIME'], 'custom', $default_long_custom))),
);
$form = system_settings_form($form);
......@@ -1697,7 +1697,7 @@ function system_date_time_settings_submit($form, &$form_state) {
* Return the date for a given format string via Ajax.
*/
function system_date_time_lookup() {
$result = format_date(time(), 'custom', $_GET['format']);
$result = format_date($_SERVER['REQUEST_TIME'], 'custom', $_GET['format']);
echo drupal_to_js($result);
exit;
}
......
......@@ -143,10 +143,10 @@ function system_requirements($phase) {
// Determine severity based on time since cron last ran.
$severity = REQUIREMENT_OK;
if (time() - $cron_last > $threshold_error) {
if ($_SERVER['REQUEST_TIME'] - $cron_last > $threshold_error) {
$severity = REQUIREMENT_ERROR;
}
else if ($never_run || (time() - $cron_last > $threshold_warning)) {
else if ($never_run || ($_SERVER['REQUEST_TIME'] - $cron_last > $threshold_warning)) {
$severity = REQUIREMENT_WARNING;
}
......@@ -163,7 +163,7 @@ function system_requirements($phase) {
$description = $t('Cron has not run.') . ' ' . $help;