Verified Commit f0c16a29 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3410312 by catch: Flood database backend ::isAllowed() should call ::ensureTableExists()

(cherry picked from commit a3f1255f)
parent e671b542
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -140,7 +140,9 @@ public function isAllowed($name, $threshold, $window = 3600, $identifier = NULL)
      return ($number < $threshold);
    }
    catch (\Exception $e) {
      $this->catchException($e);
      if (!$this->ensureTableExists()) {
        throw $e;
      }
      return TRUE;
    }
  }
+7 −6
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public function testAnonymous() {
    // the highest and lowest number of observed during test runs.
    // See https://www.drupal.org/project/drupal/issues/3402610
    $this->assertGreaterThanOrEqual(58, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(67, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(68, $performance_data->getQueryCount());
    $this->assertGreaterThanOrEqual(129, $performance_data->getCacheGetCount());
    $this->assertLessThanOrEqual(132, $performance_data->getCacheGetCount());
    $this->assertGreaterThanOrEqual(59, $performance_data->getCacheSetCount());
@@ -131,7 +131,7 @@ public function testLogin(): void {
    // random test failures, assert greater than equal the highest and lowest
    // number of queries observed during test runs.
    // See https://www.drupal.org/project/drupal/issues/3402610
    $this->assertLessThanOrEqual(42, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(39, $performance_data->getQueryCount());
    $this->assertGreaterThanOrEqual(39, $performance_data->getQueryCount());
    $this->assertSame(28, $performance_data->getCacheGetCount());
    $this->assertLessThanOrEqual(2, $performance_data->getCacheSetCount());
@@ -163,14 +163,15 @@ public function testLoginBlock(): void {
    $performance_data = $this->collectPerformanceData(function () use ($account) {
      $this->submitLoginForm($account);
    });
    $this->assertLessThanOrEqual(51, $performance_data->getQueryCount());
    $this->assertLessThanOrEqual(50, $performance_data->getQueryCount());
    $this->assertGreaterThanOrEqual(48, $performance_data->getQueryCount());
    $this->assertSame(30, $performance_data->getCacheGetCount());

    // This test observes a variable number of cache sets, so to avoid random
    // This test observes a variable number of cache operations, so to avoid random
    // test failures, assert greater than equal the highest and lowest number
    // observed during test runs.
    // See https://www.drupal.org/project/drupal/issues/3402610
    $this->assertLessThanOrEqual(32, $performance_data->getCacheGetCount());
    $this->assertGreaterThanOrEqual(30, $performance_data->getCacheGetCount());

    $this->assertLessThanOrEqual(4, $performance_data->getCacheSetCount());
    $this->assertGreaterThanOrEqual(1, $performance_data->getCacheSetCount());
    $this->assertSame(1, $performance_data->getCacheDeleteCount());