diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 7dc75f5..0999519 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1675,13 +1675,23 @@ function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG
       'link'        => $link,
       'user'        => $user,
       'uid'         => $user_uid,
-      'request_uri' => $base_root . request_uri(),
-      'referer'     => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
-      'ip'          => Drupal::request()->getClientIP(),
+      'request_uri' => '',
+      'referer'     => '',
+      'ip'          => '',
       // Request time isn't accurate for long processes, use time() instead.
       'timestamp'   => time(),
     );
 
+    try {
+      $request = Drupal::request();
+      $log_entry['request_uri'] = $request->getUri();
+      $log_entry['referer'] = $request->headers->get('Referer', '');
+      $log_entry['ip'] = $request->getClientIP();
+    }
+    catch (\InvalidArgumentException $e) {
+      // We are not in a request context.
+    }
+
     // Call the logging hooks to log/process the message
     foreach (module_implements('watchdog') as $module) {
       $function = $module . '_watchdog';
diff --git a/core/includes/file.inc b/core/includes/file.inc
index e3ac8ea..64ca434 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -1546,13 +1546,13 @@ function drupal_chmod($uri, $mode = NULL) {
     // that the octal permission numbers can be expressed as integers or strings
     // and will be converted correctly in both cases.
     if (is_dir($uri)) {
-      $mode = octdec(config('system.file')->get('chmod.directory'));
+      $mode = octdec(Drupal::config('system.file')->get('chmod.directory'));
       if (!$mode) {
         $mode = 0775;
       }
     }
     else {
-      $mode = octdec(config('system.file')->get('chmod.file'));
+      $mode = octdec(Drupal::config('system.file')->get('chmod.file'));
       if (!$mode) {
         $mode = 0664;
       }
