Verified Commit 867fd8e8 authored by Dave Long's avatar Dave Long
Browse files

fix: #3327662 Deleting the system.site:page.front config results in a PHP deprecation

By: tjtj
By: prabuela
By: aurbain25
By: diddism
By: quietone
By: smustgrave
By: kevinquillen
By: b.khouy
By: acbramley
(cherry picked from commit 675ec8e2)
parent dd3199e1
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ protected function getFrontPagePath() {
    // Lazy-load front page config.
    if (!isset($this->frontPage)) {
      $this->frontPage = $this->configFactory->get('system.site')
        ->get('page.front');
        ->get('page.front') ?? '';
    }
    return $this->frontPage;
  }
+2 −1
Original line number Diff line number Diff line
@@ -128,10 +128,11 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      '#title' => $this->t('Front page'),
      '#open' => TRUE,
    ];
    $frontPage = $site_config->get('page.front');
    $form['front_page']['site_frontpage'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Default front page'),
      '#default_value' => $this->aliasManager->getAliasByPath($site_config->get('page.front')),
      '#default_value' => $frontPage ? $this->aliasManager->getAliasByPath($frontPage) : '',
      '#required' => TRUE,
      '#size' => 40,
      '#description' => $this->t('Specify a relative URL to display as the front page.'),
+5 −0
Original line number Diff line number Diff line
@@ -95,6 +95,11 @@ public function testDrupalFrontPage(): void {
    $this->assertSession()->pageTextNotContains('On front page.');
    $this->drupalGet($this->nodePath);
    $this->assertSession()->pageTextContains('On front page.');

    // Test the form when page.front is null.
    $this->config('system.site')->clear('page.front')->save();
    $this->drupalGet('admin/config/system/site-information');
    $this->assertSession()->statusCodeEquals(200);
  }

}
+16 −0
Original line number Diff line number Diff line
@@ -51,6 +51,22 @@ public function testMatchPath($patterns, $paths): void {
    }
  }

  /**
   * Tests matchPath when page.front is null.
   */
  public function testMatchPathNullFront(): void {
    $config_factory_stub = $this->getConfigFactoryStub(
      [
        'system.site' => [
          'page.front' => NULL,
        ],
      ]
    );
    $route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
    $pathMatcher = new PathMatcher($config_factory_stub, $route_match);
    $this->assertTrue($pathMatcher->matchPath('/foo', '/*'));
  }

  /**
   * Provides test path data.
   *