From 8a376e4f30434de1317c93690bd12453e5222d0a Mon Sep 17 00:00:00 2001
From: Trevor Simonton <trevor@westernascent.com>
Date: Thu, 29 Nov 2012 09:47:41 -0700
Subject: [PATCH] Issue #1279680 by tmsimont and cam8001: Adjusting API for watchdog() to prevent wrong data type insertion to database

---
 core/authorize.php                                 |    2 +-
 core/includes/bootstrap.inc                        |    7 ++++---
 core/lib/Drupal/Core/ExceptionController.php       |    4 ++--
 .../lib/Drupal/system/Tests/Pager/PagerTest.php    |    2 +-
 core/update.php                                    |    2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/core/authorize.php b/core/authorize.php
index 1544aa9..7f80850 100644
--- a/core/authorize.php
+++ b/core/authorize.php
@@ -43,7 +43,7 @@
  */
 function authorize_access_denied_page() {
   drupal_add_http_header('Status', '403 Forbidden');
-  watchdog('access denied', 'authorize.php', array(), WATCHDOG_WARNING);
+  watchdog('access denied', 'authorize.php', NULL, WATCHDOG_WARNING);
   drupal_set_title('Access denied');
   return t('You are not allowed to access this page.');
 }
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 41db806..c8236ec 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1657,8 +1657,9 @@ function request_uri($omit_query_string = FALSE) {
  *   The message to store in the log. If empty, a text that contains all useful
  *   information about the passed-in exception is used.
  * @param $variables
- *   Array of variables to replace in the message on display. Defaults to the
- *   return value of drupal_decode_exception().
+ *   Array of variables to replace in the message on display or
+ *   NULL if message is already translated or not possible to
+ *   translate.
  * @param $severity
  *   The severity of the message, as per RFC 3164.
  * @param $link
@@ -1716,7 +1717,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia
  * @see watchdog_severity_levels()
  * @see hook_watchdog()
  */
-function watchdog($type, $message, array $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
+function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG_NOTICE, $link = NULL) {
   global $user, $base_root;
 
   static $in_error_state = FALSE;
diff --git a/core/lib/Drupal/Core/ExceptionController.php b/core/lib/Drupal/Core/ExceptionController.php
index 92d4454..d08e1cf 100644
--- a/core/lib/Drupal/Core/ExceptionController.php
+++ b/core/lib/Drupal/Core/ExceptionController.php
@@ -99,7 +99,7 @@ public function on405Html(FlattenException $exception, Request $request) {
    */
   public function on403Html(FlattenException $exception, Request $request) {
     $system_path = $request->attributes->get('system_path');
-    watchdog('access denied', $system_path, array(), WATCHDOG_WARNING);
+    watchdog('access denied', $system_path, NULL, WATCHDOG_WARNING);
 
     $path = $this->container->get('path.alias_manager')->getSystemPath(config('system.site')->get('page.403'));
     if ($path && $path != $system_path) {
@@ -153,7 +153,7 @@ public function on403Html(FlattenException $exception, Request $request) {
    *   The request object that triggered this exception.
    */
   public function on404Html(FlattenException $exception, Request $request) {
-    watchdog('page not found', check_plain($request->attributes->get('system_path')), array(), WATCHDOG_WARNING);
+    watchdog('page not found', check_plain($request->attributes->get('system_path')), NULL, WATCHDOG_WARNING);
 
     // Check for and return a fast 404 page if configured.
     $exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php
index 190cccd..bb27fa0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php
@@ -37,7 +37,7 @@ function setUp() {
 
     // Insert 300 log messages.
     for ($i = 0; $i < 300; $i++) {
-      watchdog('pager_test', $this->randomString(), array(), WATCHDOG_DEBUG);
+      watchdog('pager_test', $this->randomString(), NULL, WATCHDOG_DEBUG);
     }
 
     $this->admin_user = $this->drupalCreateUser(array(
diff --git a/core/update.php b/core/update.php
index 8563657..cc546e2 100644
--- a/core/update.php
+++ b/core/update.php
@@ -306,7 +306,7 @@ function update_info_page() {
  */
 function update_access_denied_page() {
   drupal_add_http_header('Status', '403 Forbidden');
-  watchdog('access denied', 'update.php', array(), WATCHDOG_WARNING);
+  watchdog('access denied', 'update.php', NULL, WATCHDOG_WARNING);
   drupal_set_title('Access denied');
   return '<p>Access denied. You are not authorized to access this page. Log in using either an account with the <em>administer software updates</em> permission or the site maintenance account (the account you created during installation). If you cannot log in, you will have to edit <code>settings.php</code> to bypass this access check. To do this:</p>
 <ol>
-- 
1.7.4.msysgit.0

