From 7512a3e9c8a8e7c065062243cbd902656c22c730 Mon Sep 17 00:00:00 2001
From: lucashedding <lucashedding@1463982.no-reply.drupal.org>
Date: Thu, 5 Dec 2019 16:28:55 -0600
Subject: [PATCH] Issue #3097799 by heddn: Core files modifications not
 detected

---
 src/Controller/ReadinessCheckerController.php |  2 +-
 src/Services/InPlaceUpdate.php                |  2 +-
 src/Services/ModifiedFiles.php                | 18 ++++++++++--------
 src/Services/ModifiedFilesInterface.php       |  4 +---
 tests/src/Functional/AutomaticUpdatesTest.php |  2 +-
 5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/Controller/ReadinessCheckerController.php b/src/Controller/ReadinessCheckerController.php
index 869c6b25e8..d49d0d4af8 100644
--- a/src/Controller/ReadinessCheckerController.php
+++ b/src/Controller/ReadinessCheckerController.php
@@ -55,7 +55,7 @@ class ReadinessCheckerController extends ControllerBase {
     }
     $messages = array_merge(...$messages);
     if (empty($messages)) {
-      $this->messenger()->addStatus($this->t('No issues found. Your site is completely ready for <a href="@readiness_checks">automatic updates</a>.', ['@readiness_checks' => 'https://www.drupal.org/docs/8/update/automatic-updates#readiness-checks']));
+      $this->messenger()->addStatus($this->t('No issues found. Your site is ready for <a href="@readiness_checks">automatic updates</a>.', ['@readiness_checks' => 'https://www.drupal.org/docs/8/update/automatic-updates#readiness-checks']));
     }
     return $this->redirect('automatic_updates.settings');
   }
diff --git a/src/Services/InPlaceUpdate.php b/src/Services/InPlaceUpdate.php
index 3bb44a114a..c226d6fd60 100644
--- a/src/Services/InPlaceUpdate.php
+++ b/src/Services/InPlaceUpdate.php
@@ -220,7 +220,7 @@ class InPlaceUpdate implements UpdateInterface {
     /** @var \Drupal\automatic_updates\Services\ModifiedFilesInterface $modified_files */
     $modified_files = \Drupal::service('automatic_updates.modified_files');
     try {
-      $files = iterator_to_array($modified_files->getModifiedFiles([$extensions[$project_name]], TRUE));
+      $files = iterator_to_array($modified_files->getModifiedFiles([$extensions[$project_name]]));
     }
     catch (RequestException $exception) {
       // While not strictly true that there are modified files, we can't be sure
diff --git a/src/Services/ModifiedFiles.php b/src/Services/ModifiedFiles.php
index 0b4473d680..c8171696c9 100644
--- a/src/Services/ModifiedFiles.php
+++ b/src/Services/ModifiedFiles.php
@@ -5,6 +5,7 @@ namespace Drupal\automatic_updates\Services;
 use Drupal\automatic_updates\IgnoredPathsTrait;
 use Drupal\automatic_updates\ProjectInfoTrait;
 use Drupal\Core\Config\ConfigFactoryInterface;
+use Drupal\Core\Logger\RfcLogLevel;
 use Drupal\Core\Url;
 use Drupal\Signify\ChecksumList;
 use Drupal\Signify\FailedCheckumFilter;
@@ -64,7 +65,7 @@ class ModifiedFiles implements ModifiedFilesInterface {
   /**
    * {@inheritdoc}
    */
-  public function getModifiedFiles(array $extensions = [], $exception_on_failure = FALSE) {
+  public function getModifiedFiles(array $extensions = []) {
     $modified_files = new \ArrayIterator();
     /** @var \GuzzleHttp\Promise\PromiseInterface[] $promises */
     $promises = $this->getHashRequests($extensions);
@@ -74,8 +75,8 @@ class ModifiedFiles implements ModifiedFilesInterface {
       'fulfilled' => function (array $resource) use ($modified_files) {
         $this->processHashes($resource, $modified_files);
       },
-      'rejected' => function (RequestException $exception) use ($exception_on_failure) {
-        $this->processFailures($exception, $exception_on_failure);
+      'rejected' => function (RequestException $exception) {
+        $this->processFailures($exception);
       },
     ]))->promise()->wait();
     return $modified_files;
@@ -124,12 +125,13 @@ class ModifiedFiles implements ModifiedFilesInterface {
    *
    * @param \GuzzleHttp\Exception\RequestException $exception
    *   The request exception.
-   * @param bool $exception_on_failure
-   *   Throw exception on HTTP failures, defaults to FALSE.
    */
-  protected function processFailures(RequestException $exception, $exception_on_failure) {
-    if ($exception_on_failure) {
-      watchdog_exception('automatic_updates', $exception);
+  protected function processFailures(RequestException $exception) {
+    // Log all the exceptions, even modules that aren't the main project.
+    watchdog_exception('automatic_updates', $exception, NULL, [], RfcLogLevel::INFO);
+    // HTTP 404 is expected for modules that aren't the main project. But
+    // other error codes should complain loudly.
+    if ($exception->getCode() !== 404) {
       throw $exception;
     }
   }
diff --git a/src/Services/ModifiedFilesInterface.php b/src/Services/ModifiedFilesInterface.php
index 44566d3b88..ba46f254ee 100644
--- a/src/Services/ModifiedFilesInterface.php
+++ b/src/Services/ModifiedFilesInterface.php
@@ -13,12 +13,10 @@ interface ModifiedFilesInterface {
    * @param array $extensions
    *   The list of extensions, keyed by extension name with values an info
    *   array.
-   * @param bool $exception_on_failure
-   *   (optional) Throw exception on HTTP failures, defaults to FALSE.
    *
    * @return \Iterator
    *   The modified files.
    */
-  public function getModifiedFiles(array $extensions = [], $exception_on_failure = FALSE);
+  public function getModifiedFiles(array $extensions = []);
 
 }
diff --git a/tests/src/Functional/AutomaticUpdatesTest.php b/tests/src/Functional/AutomaticUpdatesTest.php
index e2a9a9023d..9e2bae100e 100644
--- a/tests/src/Functional/AutomaticUpdatesTest.php
+++ b/tests/src/Functional/AutomaticUpdatesTest.php
@@ -111,7 +111,7 @@ class AutomaticUpdatesTest extends BrowserTestBase {
       ->save();
     $this->drupalGet(Url::fromRoute('automatic_updates.settings'));
     $this->clickLink('run the readiness checks');
-    $this->assertSession()->pageTextContains('No issues found. Your site is completely ready for automatic updates.');
+    $this->assertSession()->pageTextContains('No issues found. Your site is ready for automatic updates.');
   }
 
 }
-- 
GitLab