diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 850ea2b0c20..878af3c822d 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -180,6 +180,11 @@ define('LANGUAGE_NEGOTIATION_PATH', 2); */ define('LANGUAGE_NEGOTIATION_DOMAIN', 3); +/** + * For convenience, define a short form of the request time global. + */ +define ('REQUEST_TIME', $_SERVER['REQUEST_TIME']); + /** * Start the timer with the specified name. If you start and stop * the same timer multiple times, the measured intervals will be @@ -816,7 +821,7 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO 'request_uri' => $base_root . request_uri(), 'referer' => $_SERVER['HTTP_REFERER'], 'ip' => ip_address(), - 'timestamp' => $_SERVER['REQUEST_TIME'], + 'timestamp' => REQUEST_TIME, ); // Call the logging hooks to log/process the message diff --git a/includes/cache.inc b/includes/cache.inc index 245726ff66a..62cbb2846a5 100644 --- a/includes/cache.inc +++ b/includes/cache.inc @@ -19,7 +19,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) <= $_SERVER['REQUEST_TIME'])) { + if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= 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 @@ -104,7 +104,7 @@ function cache_get($cid, $table = 'cache') { function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) { $fields = array( 'serialized' => 0, - 'created' => $_SERVER['REQUEST_TIME'], + 'created' => REQUEST_TIME, 'expire' => $expire, 'headers' => $headers, ); @@ -155,23 +155,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 = $_SERVER['REQUEST_TIME']; + $user->cache = 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', $_SERVER['REQUEST_TIME']); + variable_set('cache_flush', REQUEST_TIME); } - else if ($_SERVER['REQUEST_TIME'] > ($cache_flush + variable_get('cache_lifetime', 0))) { + else if (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, $_SERVER['REQUEST_TIME']); + db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, 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, $_SERVER['REQUEST_TIME']); + db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, REQUEST_TIME); } } else { diff --git a/includes/common.inc b/includes/common.inc index 69227435e25..2336e5fda06 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -903,7 +903,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(), $_SERVER['REQUEST_TIME']); + db_query("INSERT INTO {flood} (event, hostname, timestamp) VALUES ('%s', '%s', %d)", $name, ip_address(), REQUEST_TIME); } /** @@ -920,7 +920,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(), $_SERVER['REQUEST_TIME'] - 3600)); + $number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), REQUEST_TIME - 3600)); return ($number < $threshold ? TRUE : FALSE); } @@ -2104,7 +2104,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 $_SERVER['REQUEST_TIME'] as query-string instead, to enforce reload on every + // get 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); @@ -2131,7 +2131,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] .= '\n"; + $no_preprocess[$type] .= '\n"; } else { $files[$path] = $info; @@ -2583,7 +2583,7 @@ function drupal_cron_run() { $semaphore = variable_get('cron_semaphore', FALSE); if ($semaphore) { - if ($_SERVER['REQUEST_TIME'] - $semaphore > 3600) { + if (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); @@ -2601,13 +2601,13 @@ function drupal_cron_run() { register_shutdown_function('drupal_cron_cleanup'); // Lock cron semaphore - variable_set('cron_semaphore', $_SERVER['REQUEST_TIME']); + variable_set('cron_semaphore', REQUEST_TIME); // Iterate through the modules calling their cron handlers (if any): module_invoke_all('cron'); // Record cron time - variable_set('cron_last', $_SERVER['REQUEST_TIME']); + variable_set('cron_last', REQUEST_TIME); watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE); // Release cron semaphore diff --git a/includes/file.inc b/includes/file.inc index bf14efba9f6..7696163b0ae 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -643,7 +643,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE, // If we made it this far it's safe to record this file in the database. $file->status = FILE_STATUS_TEMPORARY; - $file->timestamp = $_SERVER['REQUEST_TIME']; + $file->timestamp = REQUEST_TIME; drupal_write_record('files', $file); // Add file to the cache. diff --git a/includes/form.inc b/includes/form.inc index d50c9efeb2d..06252cbf5fe 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -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', $_SERVER['REQUEST_TIME'] + $expire); + cache_set('form_' . $form_build_id, $form, 'cache_form', REQUEST_TIME + $expire); if (!empty($form_state['storage'])) { - cache_set('storage_' . $form_build_id, $form_state['storage'], 'cache_form', $_SERVER['REQUEST_TIME'] + $expire); + cache_set('storage_' . $form_build_id, $form_state['storage'], 'cache_form', 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($_SERVER['REQUEST_TIME'], 'custom', 'j'), - 'month' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'n'), - 'year' => format_date($_SERVER['REQUEST_TIME'], 'custom', 'Y')); + $element['#value'] = array('day' => format_date(REQUEST_TIME, 'custom', 'j'), + 'month' => format_date(REQUEST_TIME, 'custom', 'n'), + 'year' => format_date(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)", $_SERVER['REQUEST_TIME']); + db_query("INSERT INTO {batch} (token, timestamp) VALUES ('', %d)", REQUEST_TIME); $batch['id'] = db_last_insert_id('batch', 'bid'); // Now that we have a batch id, we can generate the redirection link in diff --git a/includes/session.inc b/includes/session.inc index 0a64c1d6fcc..46b5cadd138 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -148,18 +148,18 @@ 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, $_SERVER['REQUEST_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, 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, $_SERVER['REQUEST_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, 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 && $_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); + if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) { + db_query("UPDATE {users} SET access = %d WHERE uid = %d", REQUEST_TIME, $user->uid); } } } @@ -227,7 +227,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", $_SERVER['REQUEST_TIME'] - $lifetime); + db_query("DELETE FROM {sessions} WHERE timestamp < %d", REQUEST_TIME - $lifetime); return TRUE; } diff --git a/modules/aggregator/aggregator.admin.inc b/modules/aggregator/aggregator.admin.inc index 3fdad5c6925..8520ac4439a 100644 --- a/modules/aggregator/aggregator.admin.inc +++ b/modules/aggregator/aggregator.admin.inc @@ -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($_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")); + $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(REQUEST_TIME - $feed->checked))) : t('never')), ($feed->checked ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - 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); diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 851fc38a119..b3a31c2fa9f 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -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', $_SERVER['REQUEST_TIME']); + $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', 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', $_SERVER['REQUEST_TIME'], $feed['fid']); + db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', 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', $_SERVER['REQUEST_TIME'], $feed['fid']); + db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', 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'], $_SERVER['REQUEST_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'], 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 : $_SERVER['REQUEST_TIME']; + $timestamp = isset($entry->timestamp) ? $entry->timestamp : 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 = $_SERVER['REQUEST_TIME'] - variable_get('aggregator_clear', 9676800); + $age = 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(); diff --git a/modules/aggregator/aggregator.pages.inc b/modules/aggregator/aggregator.pages.inc index 6406cded6c9..6a37cd00cff 100644 --- a/modules/aggregator/aggregator.pages.inc +++ b/modules/aggregator/aggregator.pages.inc @@ -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($_SERVER['REQUEST_TIME'] - $item->timestamp))); + $variables['source_date'] = t('%ago ago', array('%ago' => format_interval(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($_SERVER['REQUEST_TIME'] - $item->timestamp))); + $variables['feed_age'] = t('%age old', array('%age' => format_interval(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($_SERVER['REQUEST_TIME'] - $feed->checked))); + $variables['last_checked'] = t('@time ago', array('@time' => format_interval(REQUEST_TIME - $feed->checked))); } else { $variables['last_checked'] = t('never'); diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module index 70938c0f10a..d43be71e070 100644 --- a/modules/blogapi/blogapi.module +++ b/modules/blogapi/blogapi.module @@ -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($_SERVER['REQUEST_TIME'], 'custom', 'Y-m-d H:i:s O'); + $edit['date'] = format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O'); } node_invoke_nodeapi($edit, 'blogapi new'); diff --git a/modules/comment/comment.install b/modules/comment/comment.install index 556d225d91d..ee04586969b 100644 --- a/modules/comment/comment.install +++ b/modules/comment/comment.install @@ -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', $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME']); + db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', REQUEST_TIME, REQUEST_TIME); // Unstuck node indexing timestamp if needed. if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) { - variable_set('node_cron_last', min($_SERVER['REQUEST_TIME'], $last)); + variable_set('node_cron_last', min(REQUEST_TIME, $last)); } return array(); diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 4bf15133aac..c9f87321c32 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -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)) . '
' . t('@time ago', array('@time' => format_interval($_SERVER['REQUEST_TIME'] - $comment->timestamp))); + $items[] = l($comment->subject, 'node/' . $comment->nid, array('fragment' => 'comment-' . $comment->cid)) . '
' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->timestamp))); } if ($items) { @@ -712,7 +712,7 @@ function comment_save($edit) { } if (empty($edit['timestamp'])) { - $edit['timestamp'] = $_SERVER['REQUEST_TIME']; + $edit['timestamp'] = 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'] : $_SERVER['REQUEST_TIME']; + $comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : 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], $_SERVER['REQUEST_TIME'] + 31536000, '/'); + setcookie('comment_info_' . $field, $form_state['values'][$field], REQUEST_TIME + 31536000, '/'); } } } diff --git a/modules/dblog/dblog.test b/modules/dblog/dblog.test index 122a55b0fdd..ef473017646 100644 --- a/modules/dblog/dblog.test +++ b/modules/dblog/dblog.test @@ -104,7 +104,7 @@ class DBLogTestCase extends DrupalWebTestCase { 'request_uri' => $base_root . request_uri(), 'referer' => $_SERVER['HTTP_REFERER'], 'ip' => ip_address(), - 'timestamp' => $_SERVER['REQUEST_TIME'], + 'timestamp' => REQUEST_TIME, ); $message = 'Log entry added to test the dblog row limit.'; for ($i = 0; $i < $count; $i++) { diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 9dd7a7e3a34..3fdbba6cee6 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -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', $_SERVER['REQUEST_TIME'] + (60 * 60 * 24)); + cache_set($cache_id, $text, 'cache_filter', REQUEST_TIME + (60 * 60 * 24)); } } else { diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 987e37dc7a2..e550bddccec 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -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($_SERVER['REQUEST_TIME'] - $variables['topic']->timestamp) : ''; + $variables['time'] = isset($variables['topic']->timestamp) ? format_interval(REQUEST_TIME - $variables['topic']->timestamp) : ''; } function _forum_user_last_visit($nid) { diff --git a/modules/node/node.module b/modules/node/node.module index f5951d3d3c6..c23410380b3 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -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', $_SERVER['REQUEST_TIME'] - 30 * 24 * 60 * 60); +define('NODE_NEW_LIMIT', 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', $_SERVER['REQUEST_TIME'], $user->uid, $nid); + db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', REQUEST_TIME, $user->uid, $nid); } else { - @db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, $_SERVER['REQUEST_TIME']); + @db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, REQUEST_TIME); } } } @@ -880,7 +880,7 @@ function node_submit($node) { $node->uid = 0; } } - $node->created = !empty($node->date) ? strtotime($node->date) : $_SERVER['REQUEST_TIME']; + $node->created = !empty($node->date) ? strtotime($node->date) : 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 = $_SERVER['REQUEST_TIME']; + $node->created = REQUEST_TIME; } // The changed timestamp is always updated for bookkeeping purposes (revisions, searching, ...) - $node->changed = $_SERVER['REQUEST_TIME']; + $node->changed = REQUEST_TIME; - $node->timestamp = $_SERVER['REQUEST_TIME']; + $node->timestamp = 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'", $_SERVER['REQUEST_TIME']); + db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", REQUEST_TIME); return; case 'status': diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index 74227ce4d83..f59c22c917c 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -80,7 +80,7 @@ function node_object_prepare(&$node) { } global $user; $node->uid = $user->uid; - $node->created = $_SERVER['REQUEST_TIME']; + $node->created = 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 = $_SERVER['REQUEST_TIME']; + $node->changed = REQUEST_TIME; // Extract a teaser, if it hasn't been set (e.g. by a module-provided // 'teaser' form item). diff --git a/modules/openid/openid.module b/modules/openid/openid.module index c44d95a1d32..fb390a27d0a 100644 --- a/modules/openid/openid.module +++ b/modules/openid/openid.module @@ -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", $_SERVER['REQUEST_TIME']); + db_query("DELETE FROM {openid_association} WHERE created + expires_in < %d", 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'], $_SERVER['REQUEST_TIME']); + $op_endpoint, $assoc_response['session_type'], $assoc_response['assoc_handle'], $assoc_response['assoc_type'], $assoc_response['expires_in'], $assoc_response['mac_key'], REQUEST_TIME); $assoc_handle = $assoc_response['assoc_handle']; } diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 4c4962a9730..49fc6d00f14 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -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) < ' . $_SERVER['REQUEST_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) < ' . 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); } diff --git a/modules/search/search.module b/modules/search/search.module index 152fb45eb98..467f85ff366 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -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'", $_SERVER['REQUEST_TIME'], $nid); + db_query("UPDATE {search_dataset} SET reindex = %d WHERE sid = %d AND type = 'node'", REQUEST_TIME, $nid); } /** diff --git a/modules/search/search.test b/modules/search/search.test index 8535b653119..1310527a28e 100644 --- a/modules/search/search.test +++ b/modules/search/search.test @@ -305,7 +305,7 @@ class SearchRankingTestCase extends DrupalWebTestCase { $settings['body'] .= " really rocks"; break; case 'recent': - $settings['created'] = $_SERVER['REQUEST_TIME'] + 3600; + $settings['created'] = REQUEST_TIME + 3600; break; case 'comments': $settings['comment'] = 2; diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 08927d7a730..beaee6a91f6 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -369,7 +369,7 @@ class DrupalWebTestCase { 'body' => $this->randomName(32), 'title' => $this->randomName(8), 'comment' => 2, - 'changed' => $_SERVER['REQUEST_TIME'], + 'changed' => REQUEST_TIME, 'format' => FILTER_FORMAT_DEFAULT, 'moderate' => 0, 'promote' => 0, diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index d7154712c7b..9dae5d76a95 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -428,7 +428,7 @@ class FileCopyDeleteMoveTest extends DrupalWebTestCase { touch($f->filepath); $f->filemime = 'text/plain'; $f->uid = 1; - $f->timestamp = $_SERVER['REQUEST_TIME']; + $f->timestamp = REQUEST_TIME; $f->filesize = 0; drupal_write_record('files', $f); $this->file = $f; diff --git a/modules/simpletest/tests/xmlrpc.test b/modules/simpletest/tests/xmlrpc.test index df44c0ac1d4..a2a1eee060a 100644 --- a/modules/simpletest/tests/xmlrpc.test +++ b/modules/simpletest/tests/xmlrpc.test @@ -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 = $_SERVER['REQUEST_TIME']; + $time_5 = 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 */ diff --git a/modules/statistics/statistics.admin.inc b/modules/statistics/statistics.admin.inc index f10d9ca7fc4..7295083e7a3 100644 --- a/modules/statistics/statistics.admin.inc +++ b/modules/statistics/statistics.admin.inc @@ -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($_SERVER['REQUEST_TIME'] - $referrer->last)))); + $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(REQUEST_TIME - $referrer->last)))); } if (empty($rows)) { diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index e96c09808f5..cf5378a720e 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -55,7 +55,7 @@ function statistics_exit() { 'daycount' => 1, 'totalcount' => 1, 'nid' => arg(1), - 'timestamp' => $_SERVER['REQUEST_TIME'], + 'timestamp' => REQUEST_TIME, ); db_merge('node_counter') ->fields($fields) @@ -74,7 +74,7 @@ function statistics_exit() { 'uid' => $user->uid, 'sid' => session_id(), 'timer' => timer_read('page'), - 'timestamp' => $_SERVER['REQUEST_TIME'], + 'timestamp' => REQUEST_TIME, ))->execute(); } } @@ -188,14 +188,14 @@ function statistics_user($op, &$edit, &$user) { function statistics_cron() { $statistics_timestamp = variable_get('statistics_day_timestamp', ''); - if (($_SERVER['REQUEST_TIME'] - $statistics_timestamp) >= 86400) { + if ((REQUEST_TIME - $statistics_timestamp) >= 86400) { // Reset day counts. db_query('UPDATE {node_counter} SET daycount = 0'); - variable_set('statistics_day_timestamp', $_SERVER['REQUEST_TIME']); + variable_set('statistics_day_timestamp', REQUEST_TIME); } // Clean up expired access logs. - db_query('DELETE FROM {accesslog} WHERE timestamp < %d', $_SERVER['REQUEST_TIME'] - variable_get('statistics_flush_accesslog_timer', 259200)); + db_query('DELETE FROM {accesslog} WHERE timestamp < %d', REQUEST_TIME - variable_get('statistics_flush_accesslog_timer', 259200)); } /** diff --git a/modules/statistics/statistics.test b/modules/statistics/statistics.test index 549326411e0..5081343726f 100644 --- a/modules/statistics/statistics.test +++ b/modules/statistics/statistics.test @@ -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', $_SERVER['REQUEST_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', REQUEST_TIME); } /** diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 1cde4be2bd3..1a177cfef2e 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -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($_SERVER['REQUEST_TIME'], 'custom', $f); + $date_short_choices[$f] = format_date(REQUEST_TIME, 'custom', $f); } foreach ($date_medium as $f) { - $date_medium_choices[$f] = format_date($_SERVER['REQUEST_TIME'], 'custom', $f); + $date_medium_choices[$f] = format_date(REQUEST_TIME, 'custom', $f); } foreach ($date_long as $f) { - $date_long_choices[$f] = format_date($_SERVER['REQUEST_TIME'], 'custom', $f); + $date_long_choices[$f] = format_date(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 PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date($_SERVER['REQUEST_TIME'], 'custom', $default_short_custom))), + '#description' => t('A user-defined short date format. See the PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(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 PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date($_SERVER['REQUEST_TIME'], 'custom', $default_medium_custom))), + '#description' => t('A user-defined medium date format. See the PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(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 PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date($_SERVER['REQUEST_TIME'], 'custom', $default_long_custom))), + '#description' => t('A user-defined long date format. See the PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(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($_SERVER['REQUEST_TIME'], 'custom', $_GET['format']); + $result = format_date(REQUEST_TIME, 'custom', $_GET['format']); echo drupal_to_js($result); exit; } diff --git a/modules/system/system.install b/modules/system/system.install index af2ceab3328..45a6901986b 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -143,10 +143,10 @@ function system_requirements($phase) { // Determine severity based on time since cron last ran. $severity = REQUIREMENT_OK; - if ($_SERVER['REQUEST_TIME'] - $cron_last > $threshold_error) { + if (REQUEST_TIME - $cron_last > $threshold_error) { $severity = REQUIREMENT_ERROR; } - else if ($never_run || ($_SERVER['REQUEST_TIME'] - $cron_last > $threshold_warning)) { + else if ($never_run || (REQUEST_TIME - $cron_last > $threshold_warning)) { $severity = REQUIREMENT_WARNING; } @@ -163,7 +163,7 @@ function system_requirements($phase) { $description = $t('Cron has not run.') . ' ' . $help; } else { - $summary = $t('Last run !time ago', array('!time' => format_interval($_SERVER['REQUEST_TIME'] - $cron_last))); + $summary = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last))); $description = ''; if ($severity != REQUIREMENT_OK) { $description = $t('Cron has not run recently.') . ' ' . $help; @@ -371,7 +371,7 @@ function system_install() { // presumed to be a serialized array. Install will change uid 1 immediately // anyways. So we insert the superuser here, the uid is 2 here for now, but // very soon it will be changed to 1. - db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', $_SERVER['REQUEST_TIME'], serialize(array())); + db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, serialize(array())); // This sets the above two users uid 0 (anonymous). We avoid an explicit 0 // otherwise MySQL might insert the next auto_increment value. db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", ''); diff --git a/modules/system/system.module b/modules/system/system.module index 6bc1bfc469c..87ad201ab7f 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1397,12 +1397,12 @@ function system_get_module_admin_tasks($module) { */ function system_cron() { // Cleanup the flood. - db_query('DELETE FROM {flood} WHERE timestamp < %d', $_SERVER['REQUEST_TIME'] - 3600); + db_query('DELETE FROM {flood} WHERE timestamp < %d', REQUEST_TIME - 3600); // Cleanup the batch table. - db_query('DELETE FROM {batch} WHERE timestamp < %d', $_SERVER['REQUEST_TIME'] - 864000); + db_query('DELETE FROM {batch} WHERE timestamp < %d', REQUEST_TIME - 864000); // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. - $result = db_query('SELECT * FROM {files} WHERE status = %d and timestamp < %d', FILE_STATUS_TEMPORARY, $_SERVER['REQUEST_TIME'] - DRUPAL_MAXIMUM_TEMP_FILE_AGE); + $result = db_query('SELECT * FROM {files} WHERE status = %d and timestamp < %d', FILE_STATUS_TEMPORARY, REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE); while ($file = db_fetch_object($result)) { if (file_exists($file->filepath)) { // If files that exist cannot be deleted, continue so the database remains @@ -2033,7 +2033,7 @@ function system_block_ip_action() { * Generate an array of time zones and their local time&date. */ function _system_zonelist() { - $timestamp = $_SERVER['REQUEST_TIME']; + $timestamp = REQUEST_TIME; $zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14); $zones = array(); foreach ($zonelist as $offset) { diff --git a/modules/tracker/tracker.pages.inc b/modules/tracker/tracker.pages.inc index e66bca68d9f..97d9489925d 100644 --- a/modules/tracker/tracker.pages.inc +++ b/modules/tracker/tracker.pages.inc @@ -54,7 +54,7 @@ function tracker_page($account = NULL, $set_title = FALSE) { l($node->title, "node/$node->nid") . ' ' . theme('mark', node_mark($node->nid, $node->changed)), theme('username', $node), array('class' => 'replies', 'data' => $comments), - t('!time ago', array('!time' => format_interval($_SERVER['REQUEST_TIME'] - $node->last_updated))) + t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_updated))) ); } diff --git a/modules/update/update.compare.inc b/modules/update/update.compare.inc index efca6e92899..d91d4979f49 100644 --- a/modules/update/update.compare.inc +++ b/modules/update/update.compare.inc @@ -30,7 +30,7 @@ function update_get_projects() { _update_process_info_list($projects, module_rebuild_cache(), 'module'); _update_process_info_list($projects, system_theme_data(), 'theme'); // Set the projects array into the cache table. - cache_set('update_project_projects', $projects, 'cache_update', $_SERVER['REQUEST_TIME'] + 3600); + cache_set('update_project_projects', $projects, 'cache_update', REQUEST_TIME + 3600); } } return $projects; @@ -551,7 +551,7 @@ function update_calculate_project_data($available) { drupal_alter('update_status', $projects); // Set the projects array into the cache table. - cache_set('update_project_data', $projects, 'cache_update', $_SERVER['REQUEST_TIME'] + 3600); + cache_set('update_project_data', $projects, 'cache_update', REQUEST_TIME + 3600); return $projects; } @@ -588,7 +588,7 @@ function update_project_cache($cid) { } else { $cache = cache_get($cid, 'cache_update'); - if (!empty($cache->data) && $cache->expire > $_SERVER['REQUEST_TIME']) { + if (!empty($cache->data) && $cache->expire > REQUEST_TIME) { $projects = $cache->data; } } diff --git a/modules/update/update.fetch.inc b/modules/update/update.fetch.inc index d23370296a1..4255a3a4ff7 100644 --- a/modules/update/update.fetch.inc +++ b/modules/update/update.fetch.inc @@ -52,8 +52,8 @@ function _update_refresh() { } if (!empty($available) && is_array($available)) { $frequency = variable_get('update_check_frequency', 1); - cache_set('update_info', $available, 'cache_update', $_SERVER['REQUEST_TIME'] + (60 * 60 * 24 * $frequency)); - variable_set('update_last_check', $_SERVER['REQUEST_TIME']); + cache_set('update_info', $available, 'cache_update', REQUEST_TIME + (60 * 60 * 24 * $frequency)); + variable_set('update_last_check', REQUEST_TIME); watchdog('update', 'Fetched information about all available new releases and updates.', array(), WATCHDOG_NOTICE, l(t('view'), 'admin/reports/updates')); } else { diff --git a/modules/update/update.module b/modules/update/update.module index 15ca24d2526..bb3ad973b68 100644 --- a/modules/update/update.module +++ b/modules/update/update.module @@ -276,7 +276,7 @@ function _update_requirement_check($project, $type) { function update_cron() { $frequency = variable_get('update_check_frequency', 1); $interval = 60 * 60 * 24 * $frequency; - if ($_SERVER['REQUEST_TIME'] - variable_get('update_last_check', 0) > $interval) { + if (REQUEST_TIME - variable_get('update_last_check', 0) > $interval) { update_refresh(); _update_cron_notify(); } @@ -342,7 +342,7 @@ function update_get_available($refresh = FALSE) { } } if (!$needs_refresh && ($cache = cache_get('update_info', 'cache_update')) - && $cache->expire > $_SERVER['REQUEST_TIME']) { + && $cache->expire > REQUEST_TIME) { $available = $cache->data; } elseif ($needs_refresh || $refresh) { diff --git a/modules/update/update.report.inc b/modules/update/update.report.inc index 193284f1c62..8191af6a306 100644 --- a/modules/update/update.report.inc +++ b/modules/update/update.report.inc @@ -27,7 +27,7 @@ function update_status() { */ function theme_update_report($data) { $last = variable_get('update_last_check', 0); - $output = '
' . ($last ? t('Last checked: @time ago', array('@time' => format_interval($_SERVER['REQUEST_TIME'] - $last))) : t('Last checked: never')); + $output = '
' . ($last ? t('Last checked: @time ago', array('@time' => format_interval(REQUEST_TIME - $last))) : t('Last checked: never')); $output .= ' (' . l(t('Check manually'), 'admin/reports/updates/check') . ')'; $output .= "
\n"; diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc index fa188324d99..2f1363b9edc 100644 --- a/modules/user/user.admin.inc +++ b/modules/user/user.admin.inc @@ -180,8 +180,8 @@ function user_admin_account() { } asort($users_roles); $form['roles'][$account->uid][0] = array('#markup' => theme('item_list', $users_roles)); - $form['member_for'][$account->uid] = array('#markup' => format_interval($_SERVER['REQUEST_TIME'] - $account->created)); - $form['last_access'][$account->uid] = array('#markup' => $account->access ? t('@time ago', array('@time' => format_interval($_SERVER['REQUEST_TIME'] - $account->access))) : t('never')); + $form['member_for'][$account->uid] = array('#markup' => format_interval(REQUEST_TIME - $account->created)); + $form['last_access'][$account->uid] = array('#markup' => $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never')); $form['operations'][$account->uid] = array('#markup' => l(t('edit'), "user/$account->uid/edit", array('query' => $destination))); } $form['accounts'] = array( diff --git a/modules/user/user.module b/modules/user/user.module index 905dcc3bd01..73da6787480 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -240,7 +240,7 @@ function user_save($account, $edit = array(), $category = 'account') { // Consider users edited by an administrator as logged in, if they haven't // already, so anonymous users can view the profile (if allowed). if (empty($edit['access']) && empty($account->access) && user_access('administer users')) { - $edit['access'] = $_SERVER['REQUEST_TIME']; + $edit['access'] = REQUEST_TIME; } foreach ($edit as $key => $value) { // Fields that don't pertain to the users or user_roles @@ -302,12 +302,12 @@ function user_save($account, $edit = array(), $category = 'account') { else { // Allow 'created' to be set by the caller. if (!isset($edit['created'])) { - $edit['created'] = $_SERVER['REQUEST_TIME']; + $edit['created'] = REQUEST_TIME; } // Consider users created by an administrator as already logged in, so // anonymous users can view the profile (if allowed). if (empty($edit['access']) && user_access('administer users')) { - $edit['access'] = $_SERVER['REQUEST_TIME']; + $edit['access'] = REQUEST_TIME; } $success = drupal_write_record('users', $edit); @@ -653,7 +653,7 @@ function user_user($type, &$edit, &$account, $category = NULL) { $account->content['summary']['member_for'] = array( '#type' => 'user_profile_item', '#title' => t('Member for'), - '#markup' => format_interval($_SERVER['REQUEST_TIME'] - $account->created), + '#markup' => format_interval(REQUEST_TIME - $account->created), ); } if ($type == 'form' && $category == 'account') { @@ -788,7 +788,7 @@ function user_block($op = 'list', $delta = '', $edit = array()) { case 'online': if (user_access('access content')) { // Count users active within the defined period. - $interval = $_SERVER['REQUEST_TIME'] - variable_get('user_block_seconds_online', 900); + $interval = REQUEST_TIME - variable_get('user_block_seconds_online', 900); // Perform database queries to gather online user lists. We use s.timestamp // rather than u.access because it is much faster. @@ -1341,7 +1341,7 @@ function user_authenticate_finalize(&$edit) { watchdog('user', 'Session opened for %name.', array('%name' => $user->name)); // Update the user table timestamp noting user has logged in. // This is also used to invalidate one-time login links. - $user->login = $_SERVER['REQUEST_TIME']; + $user->login = REQUEST_TIME; db_query("UPDATE {users} SET login = %d WHERE uid = %d", $user->login, $user->uid); user_module_invoke('login', $edit, $user); drupal_session_regenerate(); @@ -1380,7 +1380,7 @@ function user_external_login_register($name, $module) { 'pass' => user_password(), 'init' => $name, 'status' => 1, - 'access' => $_SERVER['REQUEST_TIME'] + 'access' => REQUEST_TIME ); $account = user_save('', $userinfo); // Terminate if an error occured during user_save(). @@ -1395,7 +1395,7 @@ function user_external_login_register($name, $module) { } function user_pass_reset_url($account) { - $timestamp = $_SERVER['REQUEST_TIME']; + $timestamp = REQUEST_TIME; return url("user/reset/$account->uid/$timestamp/" . user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE)); } @@ -2040,7 +2040,7 @@ function user_mail_tokens($account, $language) { '!uri' => $base_url, '!uri_brief' => preg_replace('!^https?://!', '', $base_url), '!mailto' => $account->mail, - '!date' => format_date($_SERVER['REQUEST_TIME'], 'medium', '', NULL, $language->language), + '!date' => format_date(REQUEST_TIME, 'medium', '', NULL, $language->language), '!login_uri' => url('user', array('absolute' => TRUE, 'language' => $language)), '!edit_uri' => url('user/' . $account->uid . '/edit', array('absolute' => TRUE, 'language' => $language)), ); diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc index be757643b4c..727b2443e67 100644 --- a/modules/user/user.pages.inc +++ b/modules/user/user.pages.inc @@ -84,7 +84,7 @@ function user_pass_reset(&$form_state, $uid, $timestamp, $hashed_pass, $action = else { // Time out, in seconds, until login URL expires. 24 hours = 86400 seconds. $timeout = 86400; - $current = $_SERVER['REQUEST_TIME']; + $current = REQUEST_TIME; // Some redundant checks for extra security ? if ($timestamp < $current && $account = user_load(array('uid' => $uid, 'status' => 1)) ) { // No time out for first time login. diff --git a/modules/user/user.test b/modules/user/user.test index 5359a1564f1..7110276b7d5 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -43,7 +43,7 @@ class UserRegistrationTestCase extends DrupalWebTestCase { $this->assertEqual($user->mail, $mail, t('E-mail address matches.')); $this->assertEqual($user->theme, '', t('Correct theme field.')); $this->assertEqual($user->signature, '', t('Correct signature field.')); - $this->assertTrue(($user->created > $_SERVER['REQUEST_TIME'] - 20 ), t('Correct creation time.')); + $this->assertTrue(($user->created > REQUEST_TIME - 20 ), t('Correct creation time.')); $this->assertEqual($user->status, variable_get('user_register', 1) == 1 ? 1 : 0, t('Correct status field.')); $this->assertEqual($user->timezone, variable_get('date_default_timezone', NULL), t('Correct timezone field.')); $this->assertEqual($user->language, '', t('Correct language field.'));