diff --git a/core/lib/Drupal/Core/Update/UpdateKernel.php b/core/lib/Drupal/Core/Update/UpdateKernel.php index c24688f..cc93088 100755 --- a/core/lib/Drupal/Core/Update/UpdateKernel.php +++ b/core/lib/Drupal/Core/Update/UpdateKernel.php @@ -128,7 +128,7 @@ protected function setupRequestMatch(Request $request) { $args = explode('/', ltrim($path, '/')); $request->attributes->set(RouteObjectInterface::ROUTE_NAME, 'system.db_update'); - $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/update.php/{op}', ['op' => 'info'], ['_access' => 'TRUE'])); + $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $this->getContainer()->get('router.route_provider')->getRouteByName('system.db_update')); $op = $args[0] ?: 'info'; $request->attributes->set('op', $op); $request->attributes->set('_raw_variables', new ParameterBag(['op' => $op])); diff --git a/core/modules/system/src/Tests/Update/UpdatePathWithBrokenRoutingTest.php b/core/modules/system/src/Tests/Update/UpdatePathWithBrokenRoutingTest.php new file mode 100644 index 0000000..e9b37d1 --- /dev/null +++ b/core/modules/system/src/Tests/Update/UpdatePathWithBrokenRoutingTest.php @@ -0,0 +1,40 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz', + __DIR__ . '/../../../tests/fixtures/update/drupal-8.broken_routing.php', + ]; + parent::setUp(); + } + + /** + * Tests running update.php with some form of broken routing. + */ + public function testWithBrokenRouting() { + \Drupal::state()->set('update_script_test_broken_inbound', TRUE); + + $this->runUpdates(); + \Drupal::state()->set('update_script_test_broken_inbound', FALSE); + $this->drupalGet(''); + $this->assertResponse(200); + } + +} diff --git a/core/modules/system/tests/fixtures/update/drupal-8.broken_routing.php b/core/modules/system/tests/fixtures/update/drupal-8.broken_routing.php new file mode 100644 index 0000000..3c5e9af --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.broken_routing.php @@ -0,0 +1,18 @@ +query("SELECT data FROM {config} where name = :name", [':name' => 'core.extension'])->fetchField()); +$config['module']['update_script_test'] = 0; +$connection->update('config') + ->fields(['data' => serialize($config)]) + ->condition('name', 'core.extension') + ->execute(); + +$connection->insert('key_value') + ->fields(['collection' => 'system.schema', 'name' => 'update_script_test', 'value' => serialize(8000)]) + ->execute(); + diff --git a/core/modules/system/tests/modules/update_script_test/src/PathProcessor/BrokenInboundPathProcessor.php b/core/modules/system/tests/modules/update_script_test/src/PathProcessor/BrokenInboundPathProcessor.php new file mode 100644 index 0000000..24f15d0 --- /dev/null +++ b/core/modules/system/tests/modules/update_script_test/src/PathProcessor/BrokenInboundPathProcessor.php @@ -0,0 +1,48 @@ +state = $state; + } + + /** + * {@inheritdoc} + */ + public function processInbound($path, Request $request) { + if ($this->state->get('update_script_test_broken_inbound', FALSE)) { + throw new \RuntimeException(); + } + else { + return $path; + } + } + +} diff --git a/core/modules/system/tests/modules/update_script_test/update_script_test.services.yml b/core/modules/system/tests/modules/update_script_test/update_script_test.services.yml new file mode 100644 index 0000000..82446ed --- /dev/null +++ b/core/modules/system/tests/modules/update_script_test/update_script_test.services.yml @@ -0,0 +1,7 @@ +services: + update_script_test.broken_path_processor: + class: Drupal\update_script_test\PathProcessor\BrokenInboundPathProcessor + arguments: ['@state'] + tags: + - { name: path_processor_inbound, priority: 1000 } +