Index: includes/batch.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/batch.inc,v
retrieving revision 1.28
diff -u -p -r1.28 batch.inc
--- includes/batch.inc	10 Nov 2008 05:22:56 -0000	1.28
+++ includes/batch.inc	25 Nov 2008 22:27:39 -0000
@@ -194,7 +194,7 @@ function _batch_process() {
     // We assume a single pass operation and set the completion level
     // to 1 by default.
     $finished = 1;
-    if ((list($function, $args) = reset($current_set['operations'])) && function_exists($function)) {
+    if ((list($function, $args) = reset($current_set['operations'])) && drupal_function_exists($function)) {
       // Build the 'context' array, execute the function call,
       // and retrieve the user message.
       $batch_context = array('sandbox' => &$current_set['sandbox'], 'results' => &$current_set['results'], 'finished' => &$finished, 'message' => &$task_message);
@@ -289,7 +289,7 @@ function _batch_next_set() {
   if (isset($batch['sets'][$batch['current_set'] + 1])) {
     $batch['current_set']++;
     $current_set =& _batch_current_set();
-    if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && function_exists($function)) {
+    if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && drupal_function_exists($function)) {
       // We use our stored copies of $form and $form_state, to account for
       // possible alteration by the submit handlers.
       $function($batch['form'], $batch['form_state']);
@@ -313,7 +313,7 @@ function _batch_finished() {
       if (isset($batch_set['file']) && is_file($batch_set['file'])) {
         include_once DRUPAL_ROOT . '/' . $batch_set['file'];
       }
-      if (function_exists($batch_set['finished'])) {
+      if (drupal_function_exists($batch_set['finished'])) {
         $batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations']);
       }
     }
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.831
diff -u -p -r1.831 common.inc
--- includes/common.inc	23 Nov 2008 16:54:47 -0000	1.831
+++ includes/common.inc	25 Nov 2008 22:27:40 -0000
@@ -2790,7 +2790,22 @@ function _drupal_bootstrap_full() {
   // Undo magic quotes
   fix_gpc_magic();
   // Load all enabled modules
-  module_load_all();
+  if (defined('MAINTENANCE_MODE')) {
+    module_load_all();
+  }
+  else {
+    $required_modules = array(
+      'user',
+      'filter',
+      'node',
+      'menu',
+      'block',
+      'system',
+    );
+    foreach ($required_modules as $module) {
+      require_once DRUPAL_ROOT . "/modules/$module/$module.module";
+    }
+  }
 
   // Let all modules take action before menu system handles the request
   // We do not want this while running update.php.
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.195
diff -u -p -r1.195 locale.inc
--- includes/locale.inc	16 Nov 2008 19:41:14 -0000	1.195
+++ includes/locale.inc	25 Nov 2008 22:27:41 -0000
@@ -2,6 +2,16 @@
 // $Id: locale.inc,v 1.195 2008/11/16 19:41:14 dries Exp $
 
 /**
+ * Language written left to right. Possible value of $language->direction.
+ */
+define('LANGUAGE_LTR', 0);
+
+/**
+ * Language written right to left. Possible value of $language->direction.
+ */
+define('LANGUAGE_RTL', 1);
+
+/**
  * @file
  * Administration functions for locale.module.
  */
@@ -545,7 +555,9 @@ function locale_translate_seek_screen() 
  */
 function locale_translate_seek_form() {
   // Get all languages, except English
-  $languages = locale_language_list('name', TRUE);
+  if (drupal_function_exists('locale_language_list')) {
+    $languages = locale_language_list('name', TRUE);
+  }
   unset($languages['en']);
 
   // Present edit form preserving previous user settings
@@ -598,7 +610,9 @@ function locale_translate_seek_form() {
  */
 function locale_translate_import_form() {
   // Get all languages, except English
-  $names = locale_language_list('name', TRUE);
+  if (drupal_function_exists('locale_language_list')) {
+    $names = locale_language_list('name', TRUE);
+  }
   unset($names['en']);
 
   if (!count($names)) {
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.306
diff -u -p -r1.306 menu.inc
--- includes/menu.inc	15 Nov 2008 11:45:03 -0000	1.306
+++ includes/menu.inc	25 Nov 2008 22:27:41 -0000
@@ -458,7 +458,9 @@ function _menu_load_objects(&$item, &$ma
           $return = call_user_func_array($function, $args);
         }
         else {
-          $return = $function($value);
+          if (drupal_function_exists($function)) {
+            $return = $function($value);
+          }
         }
         // If callback returned an error or there is no callback, trigger 404.
         if ($return === FALSE) {
@@ -500,7 +502,9 @@ function _menu_check_access(&$item, $map
       $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
     }
     else {
-      $item['access'] = call_user_func_array($callback, $arguments);
+      if (drupal_function_exists($callback)) {
+        $item['access'] = call_user_func_array($callback, $arguments);
+      }
     }
   }
 }
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.134
diff -u -p -r1.134 module.inc
--- includes/module.inc	24 Nov 2008 10:41:39 -0000	1.134
+++ includes/module.inc	25 Nov 2008 22:27:41 -0000
@@ -207,7 +207,7 @@ function _module_build_dependencies($fil
  *   TRUE if the module is both installed and enabled.
  */
 function module_exists($module) {
-  $list = module_list();
+  $list = module_list(FALSE, FALSE);
   return isset($list[$module]);
 }
 
Index: modules/blogapi/blogapi.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v
retrieving revision 1.133
diff -u -p -r1.133 blogapi.module
--- modules/blogapi/blogapi.module	11 Nov 2008 16:49:37 -0000	1.133
+++ modules/blogapi/blogapi.module	25 Nov 2008 22:27:42 -0000
@@ -879,13 +879,13 @@ function _blogapi_mt_extra(&$node, $stru
   if (array_key_exists('mt_allow_comments', $struct)) {
     switch ($struct['mt_allow_comments']) {
       case 0:
-        $node->comment = COMMENT_NODE_DISABLED;
+        $node->comment = Comment::NODE_DISABLED;
         break;
       case 1:
-        $node->comment = COMMENT_NODE_READ_WRITE;
+        $node->comment = Comment::NODE_READ_WRITE;
         break;
       case 2:
-        $node->comment = COMMENT_NODE_READ_ONLY;
+        $node->comment = Comment::NODE_READ_ONLY;
         break;
     }
   }
Index: modules/comment/comment-wrapper.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment-wrapper.tpl.php,v
retrieving revision 1.4
diff -u -p -r1.4 comment-wrapper.tpl.php
--- modules/comment/comment-wrapper.tpl.php	14 May 2008 13:12:40 -0000	1.4
+++ modules/comment/comment-wrapper.tpl.php	25 Nov 2008 22:27:42 -0000
@@ -14,13 +14,13 @@
  * The constants below the variables show the possible values and should be
  * used for comparison.
  * - $display_mode
- *   - COMMENT_MODE_FLAT_COLLAPSED
- *   - COMMENT_MODE_FLAT_EXPANDED
- *   - COMMENT_MODE_THREADED_COLLAPSED
- *   - COMMENT_MODE_THREADED_EXPANDED
+ *   - Comment::MODE_FLAT_COLLAPSED
+ *   - Comment::MODE_FLAT_EXPANDED
+ *   - Comment::MODE_THREADED_COLLAPSED
+ *   - Comment::MODE_THREADED_EXPANDED
  * - $display_order
- *   - COMMENT_ORDER_NEWEST_FIRST
- *   - COMMENT_ORDER_OLDEST_FIRST
+ *   - Comment::ORDER_NEWEST_FIRST
+ *   - Comment::ORDER_OLDEST_FIRST
  *
  * @see template_preprocess_comment_wrapper()
  * @see theme_comment_wrapper()
Index: modules/comment/comment.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v
retrieving revision 1.11
diff -u -p -r1.11 comment.admin.inc
--- modules/comment/comment.admin.inc	11 Nov 2008 21:44:01 -0000	1.11
+++ modules/comment/comment.admin.inc	25 Nov 2008 22:27:42 -0000
@@ -43,7 +43,7 @@ function comment_admin_overview($type = 
     '#suffix' => '</div>',
   );
   $options = array();
-  foreach (comment_operations($arg == 'approval' ? 'publish' : 'unpublish') as $key => $value) {
+  foreach (module_invoke('comment', 'operations', $arg == 'approval' ? 'publish' : 'unpublish') as $key => $value) {
     $options[$key] = $value[0];
   }
   $form['options']['operation'] = array(
@@ -57,7 +57,7 @@ function comment_admin_overview($type = 
   );
 
   // Load the comments that need to be displayed.
-  $status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
+  $status = ($arg == 'approval') ? Comment::NOT_PUBLISHED : Comment::PUBLISHED;
   $form['header'] = array(
     '#type' => 'value',
     '#value' => array(
@@ -131,7 +131,9 @@ function comment_admin_overview_submit($
         $query
           ->condition('cid', $cid )
           ->execute();
-        $comment = comment_load($cid);
+        if (drupal_function_exists('comment_load')) {
+          $comment = comment_load($cid);
+        }
         _comment_update_node_statistics($comment->nid);
         // Allow modules to respond to the updating of a comment.
         comment_invoke_comment($comment, $form_state['values']['operation']);
@@ -201,7 +203,9 @@ function comment_multiple_delete_confirm
   // array_filter() returns only elements with actual values.
   $comment_counter = 0;
   foreach (array_filter($edit['comments']) as $cid => $value) {
-    $comment = comment_load($cid);
+    if (drupal_function_exists('comment_load')) {
+      $comment = comment_load($cid);
+    }
     if (is_object($comment) && is_numeric($comment->cid)) {
       $subject = db_result(db_query('SELECT subject FROM {comments} WHERE cid = %d', $cid));
       $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '<li>', '#suffix' => check_plain($subject) . '</li>');
@@ -228,7 +232,9 @@ function comment_multiple_delete_confirm
 function comment_multiple_delete_confirm_submit($form, &$form_state) {
   if ($form_state['values']['confirm']) {
     foreach ($form_state['values']['comments'] as $cid => $value) {
-      $comment = comment_load($cid);
+      if (drupal_function_exists('comment_load')) {
+        $comment = comment_load($cid);
+      }
       // Perform the actual comment deletion.
       _comment_delete_thread($comment);
       _comment_update_node_statistics($comment->nid);
Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.27
diff -u -p -r1.27 comment.install
--- modules/comment/comment.install	15 Nov 2008 13:01:05 -0000	1.27
+++ modules/comment/comment.install	25 Nov 2008 22:27:42 -0000
@@ -45,14 +45,14 @@ function comment_update_6002() {
   // constants defined by the module for this update.
   drupal_load('module', 'comment');
   $settings = array(
-    'comment_default_mode' => COMMENT_MODE_THREADED_EXPANDED,
-    'comment_default_order' => COMMENT_ORDER_NEWEST_FIRST,
+    'comment_default_mode' => Comment::MODE_THREADED_EXPANDED,
+    'comment_default_order' => Comment::ORDER_NEWEST_FIRST,
     'comment_default_per_page' => 50,
-    'comment_controls' => COMMENT_CONTROLS_HIDDEN,
-    'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT,
+    'comment_controls' => Comment::CONTROLS_HIDDEN,
+    'comment_anonymous' => Comment::ANONYMOUS_MAYNOT_CONTACT,
     'comment_subject_field' => 1,
-    'comment_preview' => COMMENT_PREVIEW_REQUIRED,
-    'comment_form_location' => COMMENT_FORM_SEPARATE_PAGE,
+    'comment_preview' => Comment::PREVIEW_REQUIRED,
+    'comment_form_location' => Comment::FORM_SEPARATE_PAGE,
   );
   $types = node_get_types();
   foreach ($settings as $setting => $default) {
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.666
diff -u -p -r1.666 comment.module
--- modules/comment/comment.module	23 Nov 2008 16:04:41 -0000	1.666
+++ modules/comment/comment.module	25 Nov 2008 22:27:42 -0000
@@ -10,85 +10,89 @@
  * a forum topic, weblog post, story, collaborative book page, etc.
  */
 
-/**
- * Comment is awaiting approval.
- */
-define('COMMENT_NOT_PUBLISHED', 0);
-
-/**
- * Comment is published.
- */
-define('COMMENT_PUBLISHED', 1);
-
-/**
- * Comments are displayed in a flat list - collapsed.
- */
-define('COMMENT_MODE_FLAT_COLLAPSED', 1);
-
-/**
- * Comments are displayed in a flat list - expanded.
- */
-define('COMMENT_MODE_FLAT_EXPANDED', 2);
-
-/**
- * Comments are displayed as a threaded list - collapsed.
- */
-define('COMMENT_MODE_THREADED_COLLAPSED', 3);
-
-/**
- * Comments are displayed as a threaded list - expanded.
- */
-define('COMMENT_MODE_THREADED_EXPANDED', 4);
-
-/**
- * Anonymous posters cannot enter their contact information.
- */
-define('COMMENT_ANONYMOUS_MAYNOT_CONTACT', 0);
-
-/**
- * Anonymous posters may leave their contact information.
- */
-define('COMMENT_ANONYMOUS_MAY_CONTACT', 1);
+class Comment {
 
-/**
- * Anonymous posters are required to leave their contact information.
- */
-define('COMMENT_ANONYMOUS_MUST_CONTACT', 2);
-
-/**
- * Comment form should be displayed on a separate page.
- */
-define('COMMENT_FORM_SEPARATE_PAGE', 0);
-
-/**
- * Comment form should be shown below post or list of comments.
- */
-define('COMMENT_FORM_BELOW', 1);
-
-/**
- * Comments for this node are disabled.
- */
-define('COMMENT_NODE_DISABLED', 0);
+  /**
+   * Comment is awaiting approval.
+   */
+  const NOT_PUBLISHED = 0;
+
+  /**
+   * Comment is published.
+   */
+  const PUBLISHED = 1;
+
+  /**
+   * Comments are displayed in a flat list - collapsed.
+   */
+  const MODE_FLAT_COLLAPSED = 1;
+
+  /**
+   * Comments are displayed in a flat list - expanded.
+   */
+  const MODE_FLAT_EXPANDED = 2;
+
+  /**
+   * Comments are displayed as a threaded list - collapsed.
+   */
+  const MODE_THREADED_COLLAPSED = 3;
+
+  /**
+   * Comments are displayed as a threaded list - expanded.
+   */
+  const MODE_THREADED_EXPANDED = 4;
+
+  /**
+   * Anonymous posters cannot enter their contact information.
+   */
+  const ANONYMOUS_MAYNOT_CONTACT = 0;
+
+  /**
+   * Anonymous posters may leave their contact information.
+   */
+  const ANONYMOUS_MAY_CONTACT = 1;
+
+  /**
+   * Anonymous posters are required to leave their contact information.
+   */
+  const ANONYMOUS_MUST_CONTACT = 2;
+
+  /**
+   * Comment form should be displayed on a separate page.
+   */
+  const FORM_SEPARATE_PAGE = 0;
+
+  /**
+   * Comment form should be shown below post or list of comments.
+   */
+  const FORM_BELOW = 1;
+
+  /**
+   * Comments for this node are disabled.
+   */
+  const NODE_DISABLED = 0;
+
+  /**
+   * Comments for this node are locked.
+   */
+  const NODE_READ_ONLY = 1;
+
+  /**
+   * Comments are enabled on this node.
+   */
+  const NODE_READ_WRITE = 2;
+
+  /**
+   * Comment preview is optional.
+   */
+  const PREVIEW_OPTIONAL = 0;
+
+  /**
+   * Comment preview is required.
+   */
+  const PREVIEW_REQUIRED  = 1;
 
-/**
- * Comments for this node are locked.
- */
-define('COMMENT_NODE_READ_ONLY', 1);
-
-/**
- * Comments are enabled on this node.
- */
-define('COMMENT_NODE_READ_WRITE', 2);
-
-/**
- * Comment preview is optional.
- */
-define('COMMENT_PREVIEW_OPTIONAL', 0);
-
-/**
- * Comment preview is required.
- */
-define('COMMENT_PREVIEW_REQUIRED', 1);
+}
 
 /**
  * Implementation of hook_help().
@@ -328,7 +332,7 @@ function comment_get_recent($number = 10
       ->fields('c', array('nid', 'subject', 'cid', 'timestamp') )
       ->innerJoin('node', 'n', 'n.nid = c.nid')
       ->condition('c.nid', $nids, 'IN')
-      ->condition('c.status', COMMENT_PUBLISHED)
+      ->condition('c.status', Comment::PUBLISHED)
       ->condition('n.status', 1)
       ->orderBy('c.cid', 'DESC')
       ->range(0, $number)
@@ -357,7 +361,7 @@ function comment_new_page_count($num_com
   $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
   $mode = _comment_get_display_setting('mode', $node);
   $pagenum = NULL;
-  $flat = in_array($mode, array(COMMENT_MODE_FLAT_COLLAPSED, COMMENT_MODE_FLAT_EXPANDED));
+  $flat = in_array($mode, array(Comment::MODE_FLAT_COLLAPSED, Comment::MODE_FLAT_EXPANDED));
   if ($num_comments <= $comments_per_page) {
     // Only one page of comments.
     $pageno = 0;
@@ -441,7 +445,7 @@ function comment_link($type, $node = NUL
           }
         }
         else {
-          if ($node->comment == COMMENT_NODE_READ_WRITE) {
+          if ($node->comment == Comment::NODE_READ_WRITE) {
             if (user_access('post comments')) {
               $links['comment_add'] = array(
                 'title' => t('Add new comment'),
@@ -460,9 +464,9 @@ function comment_link($type, $node = NUL
     else {
       // Node page: add a "post comment" link if the user is allowed to post comments,
       // if this node is not read-only, and if the comment form isn't already shown.
-      if ($node->comment == COMMENT_NODE_READ_WRITE) {
+      if ($node->comment == Comment::NODE_READ_WRITE) {
         if (user_access('post comments')) {
-          if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
+          if (variable_get('comment_form_location_' . $node->type, Comment::FORM_SEPARATE_PAGE) == Comment::FORM_SEPARATE_PAGE) {
             $links['comment_add'] = array(
               'title' => t('Add new comment'),
               'href' => "comment/reply/$node->nid",
@@ -503,14 +507,14 @@ function comment_form_alter(&$form, $for
     $form['comment']['comment'] = array(
       '#type' => 'radios',
       '#title' => t('Default comment setting'),
-      '#default_value' => variable_get('comment_' . $form['#node_type']->type, COMMENT_NODE_READ_WRITE),
+      '#default_value' => variable_get('comment_' . $form['#node_type']->type, Comment::NODE_READ_WRITE),
       '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
       '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
     );
     $form['comment']['comment_default_mode'] = array(
       '#type' => 'radios',
       '#title' => t('Default display mode'),
-      '#default_value' => variable_get('comment_default_mode_' . $form['#node_type']->type, COMMENT_MODE_THREADED_EXPANDED),
+      '#default_value' => variable_get('comment_default_mode_' . $form['#node_type']->type, Comment::MODE_THREADED_EXPANDED),
       '#options' => _comment_get_modes(),
       '#description' => t('Expanded views display the body of the comment. Threaded views keep replies together.'),
     );
@@ -524,11 +528,11 @@ function comment_form_alter(&$form, $for
     $form['comment']['comment_anonymous'] = array(
       '#type' => 'radios',
       '#title' => t('Anonymous commenting'),
-      '#default_value' => variable_get('comment_anonymous_' . $form['#node_type']->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT),
+      '#default_value' => variable_get('comment_anonymous_' . $form['#node_type']->type, Comment::ANONYMOUS_MAYNOT_CONTACT),
       '#options' => array(
-        COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
-        COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
-        COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),
+        Comment::ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
+        Comment::ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
+        Comment::ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),
       '#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="@url">permissions page</a>.', array('@url' => url('admin/user/permissions', array('fragment' => 'module-comment')))),
     );
 
@@ -546,14 +550,14 @@ function comment_form_alter(&$form, $for
     $form['comment']['comment_preview'] = array(
       '#type' => 'radios',
       '#title' => t('Preview comment'),
-      '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, COMMENT_PREVIEW_REQUIRED),
+      '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, Comment::PREVIEW_REQUIRED),
       '#options' => array(t('Optional'), t('Required')),
       '#description' => t("Forces a user to look at their comment by clicking on a 'Preview' button before they can actually add the comment"),
     );
     $form['comment']['comment_form_location'] = array(
       '#type' => 'radios',
       '#title' => t('Location of comment submission form'),
-      '#default_value' => variable_get('comment_form_location_' . $form['#node_type']->type, COMMENT_FORM_SEPARATE_PAGE),
+      '#default_value' => variable_get('comment_form_location_' . $form['#node_type']->type, Comment::FORM_SEPARATE_PAGE),
       '#options' => array(t('Display on separate page'), t('Display below post or comments')),
     );
   }
@@ -580,7 +584,7 @@ function comment_form_alter(&$form, $for
  * Implementation of hook_nodeapi_load().
  */
 function comment_nodeapi_load(&$node, $arg = 0) {
-  if ($node->comment != COMMENT_NODE_DISABLED) {
+  if ($node->comment != Comment::NODE_DISABLED) {
     return db_query('SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(':nid' => $node->nid))->fetchAssoc();
   }
   return array('last_comment_timestamp' => $node->created, 'last_comment_name' => '', 'comment_count' => 0);
@@ -591,7 +595,7 @@ function comment_nodeapi_load(&$node, $a
  */
 function comment_nodeapi_prepare(&$node, $arg = 0) {
   if (!isset($node->comment)) {
-    $node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
+    $node->comment = variable_get("comment_$node->type", Comment::NODE_READ_WRITE);
   }
 }
 
@@ -626,7 +630,7 @@ function comment_nodeapi_delete(&$node, 
  */
 function comment_nodeapi_update_index(&$node, $arg = 0) {
   $text = '';
-  $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED));
+  $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => Comment::PUBLISHED));
   foreach ($comments as $comment) {
     $text .= '<h2>' . check_plain($comment->subject) . '</h2>' . check_markup($comment->comment, $comment->format, FALSE);
   }
@@ -645,7 +649,7 @@ function comment_nodeapi_search_result(&
  * Implementation of hook_nodeapi_rss_item().
  */
 function comment_nodeapi_rss_item(&$node, $arg = 0) {
-  if ($node->comment != COMMENT_NODE_DISABLED) {
+  if ($node->comment != Comment::NODE_DISABLED) {
     return array(array('key' => 'comments', 'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))));
   }
   else {
@@ -712,13 +716,13 @@ function comment_node_url() {
  */
 function comment_save($edit) {
   global $user;
-  if (user_access('post comments') && (user_access('administer comments') || node_comment_mode($edit['nid']) == COMMENT_NODE_READ_WRITE)) {
+  if (user_access('post comments') && (user_access('administer comments') || node_comment_mode($edit['nid']) == Comment::NODE_READ_WRITE)) {
     if (!form_get_errors()) {
       $edit += array(
         'mail' => '',
         'homepage' => '',
         'name' => '',
-        'status' => user_access('post comments without approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED,
+        'status' => user_access('post comments without approval') ? Comment::PUBLISHED : Comment::NOT_PUBLISHED,
       );
       if ($edit['cid']) {
         // Update the comment in the database.
@@ -819,7 +823,7 @@ function comment_save($edit) {
 
       // Explain the approval queue if necessary, and then
       // redirect the user to the node he's commenting on.
-      if ($edit['status'] == COMMENT_NOT_PUBLISHED) {
+      if ($edit['status'] == Comment::NOT_PUBLISHED) {
         if (!user_access('administer comments')) {
           drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
         }
@@ -866,7 +870,7 @@ function comment_links($comment, $return
     );
   }
 
-  if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
+  if (node_comment_mode($comment->nid) == Comment::NODE_READ_WRITE) {
     if (user_access('administer comments') && user_access('post comments')) {
       $links['comment_delete'] = array(
         'title' => t('delete'),
@@ -880,7 +884,7 @@ function comment_links($comment, $return
         'title' => t('reply'),
         'href' => "comment/reply/$comment->nid/$comment->cid"
       );
-      if ($comment->status == COMMENT_NOT_PUBLISHED) {
+      if ($comment->status == Comment::NOT_PUBLISHED) {
         $links['comment_approve'] = array(
           'title' => t('approve'),
           'href' => "comment/approve/$comment->cid"
@@ -994,7 +998,7 @@ function comment_render($node, $cid = 0)
       $query->condition('c.cid', $cid);
 
       if (!user_access('administer comments')) {
-        $query->condition('c.status', COMMENT_PUBLISHED);
+        $query->condition('c.status', Comment::PUBLISHED);
       }
 
       $result = $query->execute();
@@ -1019,9 +1023,9 @@ function comment_render($node, $cid = 0)
       if (!user_access('administer comments')) {
         $query .= ' AND c.status = %d';
         $query_count .= ' AND c.status = %d';
-        $query_args[] = COMMENT_PUBLISHED;
+        $query_args[] = Comment::PUBLISHED;
       }
-      if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
+      if ($mode == Comment::MODE_FLAT_COLLAPSED || $mode == Comment::MODE_FLAT_EXPANDED) {
         $query .= ' ORDER BY c.cid';
       }
       else {
@@ -1045,7 +1049,7 @@ function comment_render($node, $cid = 0)
         $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
         $comment->depth = count(explode('.', $comment->thread)) - 1;
 
-        if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
+        if ($mode == Comment::MODE_THREADED_COLLAPSED || $mode == Comment::MODE_THREADED_EXPANDED) {
           if ($comment->depth > $divs) {
             $divs++;
             $comments .= '<div class="indented">';
@@ -1058,16 +1062,16 @@ function comment_render($node, $cid = 0)
           }
         }
 
-        if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
+        if ($mode == Comment::MODE_FLAT_COLLAPSED) {
           $comments .= theme('comment_flat_collapsed', $comment, $node);
         }
-        elseif ($mode == COMMENT_MODE_FLAT_EXPANDED) {
+        elseif ($mode == Comment::MODE_FLAT_EXPANDED) {
           $comments .= theme('comment_flat_expanded', $comment, $node);
         }
-        elseif ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
+        elseif ($mode == Comment::MODE_THREADED_COLLAPSED) {
           $comments .= theme('comment_thread_collapsed', $comment, $node);
         }
-        elseif ($mode == COMMENT_MODE_THREADED_EXPANDED) {
+        elseif ($mode == Comment::MODE_THREADED_EXPANDED) {
           $comments .= theme('comment_thread_expanded', $comment, $node);
         }
         $num_rows = TRUE;
@@ -1081,7 +1085,7 @@ function comment_render($node, $cid = 0)
 
     // If enabled, show new comment form if it's not already being displayed.
     $reply = arg(0) == 'comment' && arg(1) == 'reply';
-    if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW) && !$reply) {
+    if (user_access('post comments') && node_comment_mode($nid) == Comment::NODE_READ_WRITE && (variable_get('comment_form_location_' . $node->type, Comment::FORM_SEPARATE_PAGE) == Comment::FORM_BELOW) && !$reply) {
       $output .= comment_form_box(array('nid' => $nid), t('Post new comment'));
     }
     $output = theme('comment_wrapper', $output, $node);
@@ -1102,20 +1106,20 @@ function comment_render($node, $cid = 0)
 function comment_operations($action = NULL) {
   if ($action == 'publish') {
     $operations = array(
-      'publish' => array(t('Publish the selected comments'), db_update('comments')->fields(array( 'status' => COMMENT_PUBLISHED)) ),
+      'publish' => array(t('Publish the selected comments'), db_update('comments')->fields(array( 'status' => Comment::PUBLISHED)) ),
       'delete' => array(t('Delete the selected comments'), '')
     );
   }
   elseif ($action == 'unpublish') {
     $operations = array(
-      'unpublish' => array(t('Unpublish the selected comments'), db_update('comments')->fields(array( 'status' => COMMENT_NOT_PUBLISHED)) ),
+      'unpublish' => array(t('Unpublish the selected comments'), db_update('comments')->fields(array( 'status' => Comment::NOT_PUBLISHED)) ),
       'delete' => array(t('Delete the selected comments'), '')
     );
   }
   else {
     $operations = array(
-      'publish' => array(t('Publish the selected comments'), db_update('comments')->fields(array( 'status' => COMMENT_PUBLISHED)) ),
-      'unpublish' => array(t('Unpublish the selected comments'), db_update('comments')->fields(array( 'status' => COMMENT_NOT_PUBLISHED)) ),
+      'publish' => array(t('Publish the selected comments'), db_update('comments')->fields(array( 'status' => Comment::PUBLISHED)) ),
+      'unpublish' => array(t('Unpublish the selected comments'), db_update('comments')->fields(array( 'status' => Comment::NOT_PUBLISHED)) ),
       'delete' => array(t('Delete the selected comments'), '')
     );
   }
@@ -1153,7 +1157,7 @@ function comment_num_replies($pid) {
   if (!isset($cache[$pid])) {
     $cache[$pid] = db_query('SELECT COUNT(cid) FROM {comments} WHERE pid = :pid AND status = :status', array(
       ':pid' => $pid,
-      ':status' => COMMENT_PUBLISHED))
+      ':status' => Comment::PUBLISHED))
       ->fetchField();
   }
 
@@ -1184,7 +1188,7 @@ function comment_num_new($nid, $timestam
     return db_query('SELECT COUNT(c.cid) FROM {node} n INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = :nid AND timestamp > :timestamp AND c.status = :status', array(
       ':nid' => $nid,
       ':timestamp' => $timestamp,
-      ':status' => COMMENT_PUBLISHED ))
+      ':status' => Comment::PUBLISHED ))
       ->fetchField();
   }
   else {
@@ -1219,7 +1223,7 @@ function comment_validate($edit) {
   // Check validity of name, mail and homepage (if given).
   if (!$user->uid || isset($edit['is_anonymous'])) {
     $node = node_load($edit['nid']);
-    if (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) > COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
+    if (variable_get('comment_anonymous_' . $node->type, Comment::ANONYMOUS_MAYNOT_CONTACT) > Comment::ANONYMOUS_MAYNOT_CONTACT) {
       if ($edit['name']) {
         $query = db_select('users', 'u');
         $query->addField('u', 'uid', 'uid');
@@ -1231,7 +1235,7 @@ function comment_validate($edit) {
           form_set_error('name', t('The name you used belongs to a registered user.'));
         }
       }
-      elseif (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) {
+      elseif (variable_get('comment_anonymous_' . $node->type, Comment::ANONYMOUS_MAYNOT_CONTACT) == Comment::ANONYMOUS_MUST_CONTACT) {
         form_set_error('name', t('You have to leave your name.'));
       }
 
@@ -1240,7 +1244,7 @@ function comment_validate($edit) {
           form_set_error('mail', t('The e-mail address you specified is not valid.'));
         }
       }
-      elseif (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) {
+      elseif (variable_get('comment_anonymous_' . $node->type, Comment::ANONYMOUS_MAYNOT_CONTACT) == Comment::ANONYMOUS_MUST_CONTACT) {
         form_set_error('mail', t('You have to leave an e-mail address.'));
       }
 
@@ -1269,7 +1273,7 @@ function comment_form(&$form_state, $edi
   $op = isset($_POST['op']) ? $_POST['op'] : '';
   $node = node_load($edit['nid']);
 
-  if (!$user->uid && variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
+  if (!$user->uid && variable_get('comment_anonymous_' . $node->type, Comment::ANONYMOUS_MAYNOT_CONTACT) != Comment::ANONYMOUS_MAYNOT_CONTACT) {
     drupal_add_js(drupal_get_path('module', 'comment') . '/comment.js');
   }
   $edit += array('name' => '', 'mail' => '', 'homepage' => '');
@@ -1380,7 +1384,7 @@ function comment_form(&$form_state, $edi
       );
     }
   }
-  elseif (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MAY_CONTACT) {
+  elseif (variable_get('comment_anonymous_' . $node->type, Comment::ANONYMOUS_MAYNOT_CONTACT) == Comment::ANONYMOUS_MAY_CONTACT) {
     $form['name'] = array(
       '#type' => 'textfield',
       '#title' => t('Your name'),
@@ -1403,7 +1407,7 @@ function comment_form(&$form_state, $edi
       '#default_value' => $edit['homepage'],
     );
   }
-  elseif (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) {
+  elseif (variable_get('comment_anonymous_' . $node->type, Comment::ANONYMOUS_MAYNOT_CONTACT) == Comment::ANONYMOUS_MUST_CONTACT) {
     $form['name'] = array(
       '#type' => 'textfield',
       '#title' => t('Your name'),
@@ -1475,7 +1479,7 @@ function comment_form(&$form_state, $edi
   // already previewing the submission.  However, if there are form errors,
   // we hide the save button no matter what, so that optional form elements
   // (e.g., captchas) can be updated.
-  if (!form_get_errors() && ((variable_get('comment_preview_' . $node->type, COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) || ($op == t('Preview')) || ($op == t('Save')))) {
+  if (!form_get_errors() && ((variable_get('comment_preview_' . $node->type, Comment::PREVIEW_REQUIRED) == Comment::PREVIEW_OPTIONAL) || ($op == t('Preview')) || ($op == t('Save')))) {
     $form['submit'] = array(
       '#type' => 'submit',
       '#value' => t('Save'),
@@ -1566,7 +1570,7 @@ function comment_form_add_preview($form,
   if ($edit['pid']) {
     $comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
       ':cid' => $edit['pid'],
-      ':status' => COMMENT_PUBLISHED ))
+      ':status' => Comment::PUBLISHED ))
       ->fetchObject();
     $comment = drupal_unpack($comment);
     $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
@@ -1715,7 +1719,7 @@ function template_preprocess_comment(&$v
     $variables['status']  = 'comment-preview';
   }
   else {
-    $variables['status']  = ($comment->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : 'comment-published';
+    $variables['status']  = ($comment->status == Comment::NOT_PUBLISHED) ? 'comment-unpublished' : 'comment-published';
   }
 }
 
@@ -1806,7 +1810,7 @@ function theme_comment_post_forbidden($n
     if ($authenticated_post_comments) {
       // We cannot use drupal_get_destination() because these links
       // sometimes appear on /node and taxonomy listing pages.
-      if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
+      if (variable_get('comment_form_location_' . $node->type, Comment::FORM_SEPARATE_PAGE) == Comment::FORM_SEPARATE_PAGE) {
         $destination = 'destination=' . drupal_urlencode("comment/reply/$node->nid#comment-form");
       }
       else {
@@ -1860,10 +1864,10 @@ function theme_comment_submitted($commen
  */
 function _comment_get_modes() {
   return array(
-    COMMENT_MODE_FLAT_COLLAPSED => t('Flat list - collapsed'),
-    COMMENT_MODE_FLAT_EXPANDED => t('Flat list - expanded'),
-    COMMENT_MODE_THREADED_COLLAPSED => t('Threaded list - collapsed'),
-    COMMENT_MODE_THREADED_EXPANDED => t('Threaded list - expanded')
+    Comment::MODE_FLAT_COLLAPSED => t('Flat list - collapsed'),
+    Comment::MODE_FLAT_EXPANDED => t('Flat list - expanded'),
+    Comment::MODE_THREADED_COLLAPSED => t('Threaded list - collapsed'),
+    Comment::MODE_THREADED_EXPANDED => t('Threaded list - expanded')
   );
 }
 
@@ -1886,7 +1890,7 @@ function _comment_per_page() {
 function _comment_get_display_setting($setting, $node) {
   switch ($setting) {
     case 'mode':
-      $value = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED_EXPANDED);
+      $value = variable_get('comment_default_mode_' . $node->type, Comment::MODE_THREADED_EXPANDED);
       break;
 
     case 'comments_per_page':
@@ -1907,11 +1911,11 @@ function _comment_get_display_setting($s
  * - comment_count: the total number of approved/published comments on this node.
  */
 function _comment_update_node_statistics($nid) {
-  $count = db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = :nid AND status = :status', array(':nid' => $nid, ':status' => COMMENT_PUBLISHED))->fetchField();
+  $count = db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = :nid AND status = :status', array(':nid' => $nid, ':status' => Comment::PUBLISHED))->fetchField();
 
   if ($count > 0) {
     // Comments exist.
-    $last_reply = db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = :nid AND status = :status ORDER BY cid DESC', array(':nid' => $nid, ':status' => COMMENT_PUBLISHED), 0, 1)->fetchObject();
+    $last_reply = db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = :nid AND status = :status ORDER BY cid DESC', array(':nid' => $nid, ':status' => Comment::PUBLISHED), 0, 1)->fetchObject();
     db_update('node_comment_statistics')
       ->fields( array(
         'comment_count' => $count,
@@ -2054,7 +2058,7 @@ function comment_unpublish_action($comme
     $subject = db_query('SELECT subject FROM {comments} WHERE cid = :cid', array(':cid', $cid))->fetchField();
   }
   db_update('comments')
-    ->fields(array('status' => COMMENT_NOT_PUBLISHED,))
+    ->fields(array('status' => Comment::NOT_PUBLISHED,))
     ->condition('cid', $cid)
     ->execute();
   watchdog('action', 'Unpublished comment %subject.', array('%subject' => $subject));
@@ -2099,7 +2103,7 @@ function comment_unpublish_by_keyword_ac
   foreach ($context['keywords'] as $keyword) {
     if (strstr($comment->comment, $keyword) || strstr($comment->subject, $keyword)) {
       db_update('comments')
-        ->fields(array('status' => COMMENT_NOT_PUBLISHED,))
+        ->fields(array('status' => Comment::NOT_PUBLISHED,))
         ->condition('cid', $comment->cid)
         ->execute();
       watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
Index: modules/comment/comment.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v
retrieving revision 1.9
diff -u -p -r1.9 comment.pages.inc
--- modules/comment/comment.pages.inc	16 Nov 2008 19:41:14 -0000	1.9
+++ modules/comment/comment.pages.inc	25 Nov 2008 22:27:42 -0000
@@ -19,7 +19,7 @@ function comment_edit($cid) {
   $comment = drupal_unpack($comment);
   $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
 
-  if (comment_access('edit', $comment)) {
+  if (drupal_function_exists('comment_access') && comment_access('edit', $comment)) {
     return comment_form_box((array)$comment);
   }
   else {
@@ -71,7 +71,7 @@ function comment_reply($node, $pid = NUL
         // Load the comment whose cid = $pid
         $comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
           ':cid'=>$pid,
-          ':status'=>COMMENT_PUBLISHED))->fetchObject();
+          ':status'=> Comment::PUBLISHED))->fetchObject();
         if ( $comment ) {
           // If that comment exists, make sure that the current comment and the
           // parent comment both belong to the same parent node.
@@ -96,7 +96,7 @@ function comment_reply($node, $pid = NUL
       }
 
       // Should we show the reply box?
-      if (node_comment_mode($node->nid) != COMMENT_NODE_READ_WRITE) {
+      if (node_comment_mode($node->nid) != Comment::NODE_READ_WRITE) {
         drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
         drupal_goto("node/$node->nid");
       }
@@ -124,7 +124,7 @@ function comment_reply($node, $pid = NUL
  */
 function comment_approve($cid) {
   // Load the comment whose cid = $cid
-  if ($comment = comment_load($cid)) {
+  if (drupal_function_exists('comment_load') && $comment = comment_load($cid)) {
     $operations = comment_operations('publish');
     $query = $operations['publish'][1];
     $query
Index: modules/comment/comment.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v
retrieving revision 1.19
diff -u -p -r1.19 comment.test
--- modules/comment/comment.test	25 Nov 2008 13:14:26 -0000	1.19
+++ modules/comment/comment.test	25 Nov 2008 22:27:42 -0000
@@ -308,21 +308,21 @@ class CommentInterfaceTest extends Comme
     $this->setCommentsPerPage(50);
 
     // Attempt to post to node with comments disabled.
-    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_DISABLED));
+    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => Comment::NODE_DISABLED));
     $this->assertTrue($this->node, t('Article node created.'));
     $this->drupalGet('comment/reply/' . $this->node->nid);
     $this->assertText('This discussion is closed', t('Posting to node with comments disabled'));
     $this->assertNoField('edit-comment', t('Comment body field found.'));
 
     // Attempt to post to node with read-only comments.
-    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_READ_ONLY));
+    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => Comment::NODE_READ_ONLY));
     $this->assertTrue($this->node, t('Article node created.'));
     $this->drupalGet('comment/reply/' . $this->node->nid);
     $this->assertText('This discussion is closed', t('Posting to node with comments read-only'));
     $this->assertNoField('edit-comment', t('Comment body field found.'));
 
     // Attempt to post to node with comments enabled (check field names etc).
-    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_READ_WRITE));
+    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => Comment::NODE_READ_WRITE));
     $this->assertTrue($this->node, t('Article node created.'));
     $this->drupalGet('comment/reply/' . $this->node->nid);
     $this->assertNoText('This discussion is closed', t('Posting to node with comments enabled'));
Index: modules/contact/contact.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v
retrieving revision 1.15
diff -u -p -r1.15 contact.pages.inc
--- modules/contact/contact.pages.inc	13 Oct 2008 00:33:02 -0000	1.15
+++ modules/contact/contact.pages.inc	25 Nov 2008 22:27:43 -0000
@@ -126,7 +126,9 @@ function contact_mail_page_submit($form,
   $from = $values['mail'];
 
   // Load category properties and save form values for email composition.
-  $contact = contact_load($values['cid']);
+  if (drupal_function_exists('contact_load')) {
+    $contact = contact_load($values['cid']);
+  }
   $values['contact'] = $contact;
 
   // Send the e-mail to the recipients using the site default language.
Index: modules/forum/forum.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.admin.inc,v
retrieving revision 1.15
diff -u -p -r1.15 forum.admin.inc
--- modules/forum/forum.admin.inc	5 Nov 2008 14:08:11 -0000	1.15
+++ modules/forum/forum.admin.inc	25 Nov 2008 22:27:43 -0000
@@ -219,7 +219,7 @@ function forum_overview(&$form_state) {
   module_load_include('inc', 'taxonomy', 'taxonomy.admin');
 
   $vid = variable_get('forum_nav_vocabulary', '');
-  $vocabulary = taxonomy_vocabulary_load($vid);
+  $vocabulary = module_invoke('taxonomy', 'vocabulary_load', $vid);
   $form = taxonomy_overview_terms($form_state, $vocabulary);
   drupal_set_title('Forums');
 
@@ -256,7 +256,7 @@ function forum_overview(&$form_state) {
  */
 function _forum_parent_select($tid, $title, $child_type) {
 
-  $parents = taxonomy_get_parents($tid);
+  $parents = module_invoke('taxonomy', 'get_parents', $tid);
   if ($parents) {
     $parent = array_shift($parents);
     $parent = $parent->tid;
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.473
diff -u -p -r1.473 forum.module
--- modules/forum/forum.module	11 Nov 2008 16:49:37 -0000	1.473
+++ modules/forum/forum.module	25 Nov 2008 22:27:43 -0000
@@ -223,7 +223,7 @@ function forum_nodeapi_view(&$node, $tea
  */
 function forum_nodeapi_prepare(&$node, $teaser, $page) {
   $vid = variable_get('forum_nav_vocabulary', '');
-  $vocabulary = taxonomy_vocabulary_load($vid);
+  $vocabulary = module_invoke('taxonomy', 'vocabulary_load', $vid);
   if (_forum_nodeapi_check_node_type($node, $vocabulary)) {
     if (empty($node->nid)) {
       // New topic
@@ -555,7 +555,7 @@ function forum_get_forums($tid = 0) {
 
   $forums = array();
   $vid = variable_get('forum_nav_vocabulary', '');
-  $_forums = taxonomy_get_tree($vid, $tid);
+  $_forums = module_invoke('taxonomy', 'get_tree', $vid, $tid);
 
   if (count($_forums)) {
 
@@ -648,7 +648,7 @@ function forum_get_topics($tid, $sortby,
       }
       else {
         $history = _forum_user_last_visit($topic->nid);
-        $topic->new_replies = comment_num_new($topic->nid, $history);
+        $topic->new_replies = module_invoke('comment', 'num_new', $topic->nid, $history);
         $topic->new = $topic->new_replies || ($topic->timestamp > $history);
       }
     }
@@ -919,7 +919,7 @@ function template_preprocess_forum_icon(
     $variables['icon'] = $variables['new_posts'] ? 'new' : 'default';
   }
 
-  if ($variables['comment_mode'] == COMMENT_NODE_READ_ONLY || $variables['comment_mode'] == COMMENT_NODE_DISABLED) {
+  if ($variables['comment_mode'] == Comment::NODE_READ_ONLY || $variables['comment_mode'] == Comment::NODE_DISABLED) {
     $variables['icon'] = 'closed';
   }
 
Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.232
diff -u -p -r1.232 locale.module
--- modules/locale/locale.module	23 Nov 2008 16:00:06 -0000	1.232
+++ modules/locale/locale.module	25 Nov 2008 22:27:43 -0000
@@ -12,17 +12,6 @@
  *   Gettext portable object files are supported.
  */
 
-/**
- * Language written left to right. Possible value of $language->direction.
- */
-define('LANGUAGE_LTR', 0);
-
-/**
- * Language written right to left. Possible value of $language->direction.
- */
-define('LANGUAGE_RTL', 1);
-
-
 // ---------------------------------------------------------------------------------
 // Hook implementations
 
Index: modules/path/path.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v
retrieving revision 1.15
diff -u -p -r1.15 path.admin.inc
--- modules/path/path.admin.inc	22 Nov 2008 10:49:01 -0000	1.15
+++ modules/path/path.admin.inc	25 Nov 2008 22:27:43 -0000
@@ -64,7 +64,7 @@ function path_admin_overview($keys = NUL
  * Menu callback; handles pages for creating and editing URL aliases.
  */
 function path_admin_edit($pid = 0) {
-  if ($pid) {
+  if ($pid && drupal_function_exists('path_load')) {
     $alias = path_load($pid);
     drupal_set_title($alias['dst']);
     $output = drupal_get_form('path_admin_form', $alias);
@@ -159,7 +159,9 @@ function path_admin_form_submit($form, &
  * Menu callback; confirms deleting an URL alias
  */
 function path_admin_delete_confirm($form_state, $pid) {
-  $path = path_load($pid);
+  if (drupal_function_exists('path_load')) {
+    $path = path_load($pid);
+  }
   if (user_access('administer url aliases')) {
     $form['pid'] = array('#type' => 'value', '#value' => $pid);
     $output = confirm_form($form,
Index: modules/profile/profile.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v
retrieving revision 1.17
diff -u -p -r1.17 profile.admin.inc
--- modules/profile/profile.admin.inc	13 Oct 2008 00:33:04 -0000	1.17
+++ modules/profile/profile.admin.inc	25 Nov 2008 22:27:43 -0000
@@ -3,6 +3,11 @@
 
 /**
  * @file
+ * Support for configurable user profiles.
+ */
+
+/**
+ * @file
  * Administrative page callbacks for the profile module.
  */
 
@@ -54,8 +59,10 @@ function profile_admin_overview() {
 
   $addnewfields = '<h2>' . t('Add new field') . '</h2>';
   $addnewfields .= '<ul>';
-  foreach (_profile_field_types() as $key => $value) {
-    $addnewfields .= '<li>' . l($value, "admin/user/profile/add/$key") . '</li>';
+  if (drupal_function_exists('_profile_field_types')) {
+    foreach (_profile_field_types() as $key => $value) {
+      $addnewfields .= '<li>' . l($value, "admin/user/profile/add/$key") . '</li>';
+    }
   }
   $addnewfields .= '</ul>';
   $form['addnewfields'] = array('#markup' => $addnewfields);
@@ -187,7 +194,9 @@ function profile_field_form(&$form_state
     }
   }
   else {
-    $types = _profile_field_types();
+    if (drupal_function_exists('_profile_field_types')) {
+      $types = _profile_field_types();
+    }
     if (!isset($types[$arg])) {
       drupal_not_found();
       return;
@@ -244,8 +253,8 @@ Unless you know what you are doing, it i
   }
   $form['fields']['visibility'] = array('#type' => 'radios',
     '#title' => t('Visibility'),
-    '#default_value' => isset($edit['visibility']) ? $edit['visibility'] : PROFILE_PUBLIC,
-    '#options' => array(PROFILE_HIDDEN => t('Hidden profile field, only accessible by administrators, modules and themes.'), PROFILE_PRIVATE => t('Private field, content only available to privileged users.'), PROFILE_PUBLIC => t('Public field, content shown on profile page but not used on member list pages.'), PROFILE_PUBLIC_LISTINGS => t('Public field, content shown on profile page and on member list pages.')),
+    '#default_value' => isset($edit['visibility']) ? $edit['visibility'] : Profile::PUBLIC_FIELD,
+    '#options' => array(Profile::HIDDEN => t('Hidden profile field, only accessible by administrators, modules and themes.'), Profile::PRIVATE_FIELD => t('Private field, content only available to privileged users.'), Profile::PUBLIC_FIELD => t('Public field, content shown on profile page but not used on member list pages.'), Profile::PUBLIC_FIELD_LISTINGS => t('Public field, content shown on profile page and on member list pages.')),
   );
   if ($type == 'selection' || $type == 'list' || $type == 'textfield') {
     $form['fields']['page'] = array('#type' => 'textfield',
@@ -320,7 +329,7 @@ function profile_field_form_validate($fo
   if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'" . $query_suffix, $args2))) {
     form_set_error('name', t('The specified name is already in use.'));
   }
-  if ($form_state['values']['visibility'] == PROFILE_HIDDEN) {
+  if ($form_state['values']['visibility'] == Profile::HIDDEN) {
     if ($form_state['values']['required']) {
       form_set_error('required', t('A hidden field cannot be required.'));
     }
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.246
diff -u -p -r1.246 profile.module
--- modules/profile/profile.module	12 Oct 2008 04:30:08 -0000	1.246
+++ modules/profile/profile.module	25 Nov 2008 22:27:43 -0000
@@ -6,25 +6,29 @@
  * Support for configurable user profiles.
  */
 
-/**
- * Private field, content only available to privileged users.
- */
-define('PROFILE_PRIVATE', 1);
-
-/**
- * Public field, content shown on profile page but not used on member list pages.
- */
-define('PROFILE_PUBLIC', 2);
+class Profile {
 
-/**
- * Public field, content shown on profile page and on member list pages.
- */
-define('PROFILE_PUBLIC_LISTINGS', 3);
+  /**
+   * Private field, content only available to privileged users.
+   */
+  const PRIVATE_FIELD = 1;
+
+  /**
+   * Public field, content shown on profile page but not used on member list pages.
+   */
+  const PUBLIC_FIELD = 2;
+
+  /**
+   * Public field, content shown on profile page and on member list pages.
+   */
+  const PUBLIC_FIELD_LISTINGS = 3;
+
+  /**
+   * Hidden profile field, only accessible by administrators, modules and themes.
+   */
+  const HIDDEN = 4;
 
-/**
- * Hidden profile field, only accessible by administrators, modules and themes.
- */
-define('PROFILE_HIDDEN', 4);
+}
 
 /**
  * Implementation of hook_help().
@@ -138,7 +142,7 @@ function profile_block($op = 'list', $de
   elseif ($op == 'configure') {
     // Compile a list of fields to show
     $fields = array();
-    $result = db_query('SELECT name, title, weight, visibility FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS);
+    $result = db_query('SELECT name, title, weight, visibility FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', Profile::PUBLIC_FIELD, Profile::PUBLIC_FIELD_LISTINGS);
     while ($record = db_fetch_object($result)) {
       $fields[$record->name] = check_plain($record->title);
     }
@@ -165,7 +169,7 @@ function profile_block($op = 'list', $de
         if ($use_fields = variable_get('profile_block_author_fields', array())) {
           // Compile a list of fields to show.
           $fields = array();
-          $result = db_query('SELECT name, title, type, visibility, weight FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS);
+          $result = db_query('SELECT name, title, type, visibility, weight FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', Profile::PUBLIC_FIELD, Profile::PUBLIC_FIELD_LISTINGS);
           while ($record = db_fetch_object($result)) {
             // Ensure that field is displayed only if it is among the defined block fields and, if it is private, the user has appropriate permissions.
             if (isset($use_fields[$record->name]) && $use_fields[$record->name]) {
@@ -283,7 +287,7 @@ function profile_view_field($user, $fiel
   // and if a user has permission to view profiles. Note that this check is
   // necessary because a user may always see their own profile.
   $browse = user_access('access user profiles')
-         && (user_access('administer users') || $field->visibility != PROFILE_PRIVATE)
+         && (user_access('administer users') || $field->visibility != Profile::PRIVATE_FIELD)
          && !empty($field->page);
 
   if (isset($user->{$field->name}) && $value = $user->{$field->name}) {
@@ -331,10 +335,10 @@ function profile_view_profile(&$user) {
 
   // Show private fields to administrators and people viewing their own account.
   if (user_access('administer users') || $GLOBALS['user']->uid == $user->uid) {
-    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d ORDER BY category, weight', PROFILE_HIDDEN);
+    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d ORDER BY category, weight', Profile::HIDDEN);
   }
   else {
-    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d ORDER BY category, weight', PROFILE_PRIVATE, PROFILE_HIDDEN);
+    $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d ORDER BY category, weight', Profile::PRIVATE_FIELD, Profile::HIDDEN);
   }
 
   $fields = array();
@@ -368,7 +372,7 @@ function _profile_form_explanation($fiel
     $output .= ' ' . t('Put each item on a separate line or separate them by commas. No HTML allowed.');
   }
 
-  if ($field->visibility == PROFILE_PRIVATE) {
+  if ($field->visibility == Profile::PRIVATE_FIELD) {
     $output .= ' ' . t('The content of this field is kept private and will not be shown publicly.');
   }
 
@@ -502,7 +506,7 @@ function profile_category_access($accoun
     return TRUE;
   }
   else {
-    return user_edit_access($account) && db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE category = '%s' AND visibility <> %d", $category, PROFILE_HIDDEN));
+    return user_edit_access($account) && db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE category = '%s' AND visibility <> %d", $category, Profile::HIDDEN));
   }
 }
 
@@ -601,7 +605,7 @@ function _profile_get_fields($category, 
   }
   if (!user_access('administer users')) {
     $filters[] = 'visibility != %d';
-    $args[] = PROFILE_HIDDEN;
+    $args[] = Profile::HIDDEN;
   }
   $sql .= implode(' AND ', $filters);
   $sql .= ' ORDER BY category, weight';
Index: modules/profile/profile.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.pages.inc,v
retrieving revision 1.9
diff -u -p -r1.9 profile.pages.inc
--- modules/profile/profile.pages.inc	2 Nov 2008 16:11:31 -0000	1.9
+++ modules/profile/profile.pages.inc	25 Nov 2008 22:27:43 -0000
@@ -22,14 +22,14 @@ function profile_browse() {
       return;
     }
     // Do not allow browsing of private and hidden fields by non-admins.
-    if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
+    if (!user_access('administer users') && ($field->visibility == Profile::PRIVATE_FIELD || $field->visibility == Profile::HIDDEN)) {
       drupal_access_denied();
       return;
     }
 
     // Compile a list of fields to show.
     $fields = array();
-    $result = db_query('SELECT name, title, type, weight, page FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, PROFILE_PUBLIC_LISTINGS);
+    $result = db_query('SELECT name, title, type, weight, page FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, Profile::PUBLIC_LISTINGS);
     while ($record = db_fetch_object($result)) {
       $fields[] = $record;
     }
@@ -82,7 +82,7 @@ function profile_browse() {
   else {
     // Compile a list of fields to show.
     $fields = array();
-    $result = db_query('SELECT name, title, type, weight, page, visibility FROM {profile_fields} WHERE visibility = %d ORDER BY category, weight', PROFILE_PUBLIC_LISTINGS);
+    $result = db_query('SELECT name, title, type, weight, page, visibility FROM {profile_fields} WHERE visibility = %d ORDER BY category, weight', Profile::PUBLIC_LISTINGS);
     while ($record = db_fetch_object($result)) {
       $fields[] = $record;
     }
Index: modules/search/search.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.pages.inc,v
retrieving revision 1.5
diff -u -p -r1.5 search.pages.inc
--- modules/search/search.pages.inc	14 Apr 2008 17:48:41 -0000	1.5
+++ modules/search/search.pages.inc	25 Nov 2008 22:27:43 -0000
@@ -20,8 +20,10 @@ function search_view($type = 'node') {
       // switching tabs. This is why we drupal_goto to it from the parent instead.
       drupal_goto('search/node');
     }
-
-    $keys = search_get_keys();
+    
+    if (drupal_function_exists('search_get_keys')) {
+      $keys = search_get_keys();
+    }
     // Only perform search if there is non-whitespace search term:
     $results = '';
     if (trim($keys)) {
Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.37
diff -u -p -r1.37 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc	13 Nov 2008 08:13:56 -0000	1.37
+++ modules/taxonomy/taxonomy.admin.inc	25 Nov 2008 22:27:43 -0000
@@ -14,7 +14,7 @@
  * @see theme_taxonomy_overview_vocabularies()
  */
 function taxonomy_overview_vocabularies() {
-  $vocabularies = taxonomy_get_vocabularies();
+  $vocabularies = module_invoke('taxonomy', 'get_vocabularies');
   $form = array('#tree' => TRUE);
   foreach ($vocabularies as $vocabulary) {
     $types = array();
Index: modules/tracker/tracker.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/tracker/tracker.pages.inc,v
retrieving revision 1.12
diff -u -p -r1.12 tracker.pages.inc
--- modules/tracker/tracker.pages.inc	26 Oct 2008 18:06:39 -0000	1.12
+++ modules/tracker/tracker.pages.inc	25 Nov 2008 22:27:43 -0000
@@ -21,12 +21,12 @@ function tracker_page($account = NULL, $
       // here and not in the menu definiton.
       drupal_set_title($account->name);
     }
-  // TODO: These queries are very expensive, see http://drupal.org/node/105639
+    // TODO: These queries are very expensive, see http://drupal.org/node/105639
     $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
     $sql = db_rewrite_sql($sql);
     $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
     $sql_count = db_rewrite_sql($sql_count);
-    $result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $account->uid, $account->uid);
+    $result = pager_query($sql, 25, 0, $sql_count, Comment::PUBLISHED, $account->uid, $account->uid);
   }
   else {
     $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_updated DESC';
@@ -43,7 +43,7 @@ function tracker_page($account = NULL, $
     if ($node->comment_count) {
       $comments = $node->comment_count;
 
-      if ($new = comment_num_new($node->nid)) {
+      if (drupal_function_exists('comment_num_new') && $new = comment_num_new($node->nid)) {
         $comments .= '<br />';
         $comments .= l(format_plural($new, '1 new', '@count new'), "node/$node->nid", array('query' => comment_new_page_count($node->comment_count, $new, $node), 'fragment' => 'new'));
       }
Index: profiles/default/default.profile
===================================================================
RCS file: /cvs/drupal/drupal/profiles/default/default.profile,v
retrieving revision 1.31
diff -u -p -r1.31 default.profile
--- profiles/default/default.profile	23 Nov 2008 18:13:41 -0000	1.31
+++ profiles/default/default.profile	25 Nov 2008 22:27:43 -0000
@@ -122,7 +122,7 @@ function default_profile_tasks(&$task, $
 
   // Default page to not be promoted and have comments disabled.
   variable_set('node_options_page', array('status'));
-  variable_set('comment_page', COMMENT_NODE_DISABLED);
+  variable_set('comment_page', Comment::NODE_DISABLED);
 
   // Don't display date and author information for page nodes by default.
   $theme_settings = variable_get('theme_settings', array());
Index: themes/garland/template.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/template.php,v
retrieving revision 1.19
diff -u -p -r1.19 template.php
--- themes/garland/template.php	25 Jun 2008 09:12:25 -0000	1.19
+++ themes/garland/template.php	25 Nov 2008 22:27:44 -0000
@@ -50,7 +50,7 @@ function garland_preprocess_page(&$vars)
   $vars['site_html'] = implode(' ', $site_fields);
 
   // Hook into color.module
-  if (module_exists('color')) {
+  if (drupal_function_exists('_color_page_alter')) {
     _color_page_alter($vars);
   }
 }
