Issue #3151118 by alexpott, Beakerboy, kapilkumar0324, anmolgoyal74, jungle, heddn, Mile23, andypost, daffie: Include bootstrap.inc using composer

merge-requests/25/head
catch 2020-11-03 11:45:09 +00:00
parent a8ef4362e6
commit b72fe50a60
22 changed files with 166 additions and 234 deletions

5
composer.lock generated
View File

@ -527,7 +527,7 @@
"dist": {
"type": "path",
"url": "core",
"reference": "0809224944e41d0a5d03f65e1f7a179512647923"
"reference": "af5b9453adf15c6831b1f73e322f8c59da877f14"
},
"require": {
"asm89/stack-cors": "^1.1",
@ -752,6 +752,9 @@
"lib/Drupal/Core/DrupalKernelInterface.php",
"lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
"lib/Drupal/Core/Site/Settings.php"
],
"files": [
"includes/bootstrap.inc"
]
},
"scripts": {

View File

@ -16,7 +16,6 @@ $autoloader = require_once 'autoload.php';
// Disable garbage collection during test runs. Under certain circumstances the
// update path will create so many objects that garbage collection causes
// segmentation faults.
require_once 'core/includes/bootstrap.inc';
if (drupal_valid_test_ua()) {
gc_collect_cycles();
gc_disable();

View File

@ -198,7 +198,8 @@
"lib/Drupal/Core/DrupalKernelInterface.php",
"lib/Drupal/Core/Installer/InstallerRedirectTrait.php",
"lib/Drupal/Core/Site/Settings.php"
]
],
"files": [ "includes/bootstrap.inc" ]
},
"config": {
"preferred-install": "dist"

View File

@ -311,9 +311,6 @@ function install_begin_request($class_loader, &$install_state) {
$install_state['parameters']['langcode'] = preg_replace('/[^a-zA-Z_0-9\-]/', '', $install_state['parameters']['langcode']);
}
// Allow command line scripts to override server variables used by Drupal.
require_once __DIR__ . '/bootstrap.inc';
// If the hash salt leaks, it becomes possible to forge a valid testing user
// agent, install a new copy of Drupal, and take over the original site.
// The user agent header is used to pass a database prefix in the request when

View File

@ -984,9 +984,6 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
$app_root = static::guessApplicationRoot();
}
// Include our bootstrap file.
require_once $app_root . '/core/includes/bootstrap.inc';
// Enforce E_STRICT, but allow users to set levels not part of E_STRICT.
error_reporting(E_STRICT | E_ALL);

View File

@ -13,9 +13,6 @@ class TestKernel extends DrupalKernel {
* {@inheritdoc}
*/
public function __construct($environment, $class_loader, $allow_dumping = TRUE) {
// Include our bootstrap file.
require_once __DIR__ . '/../../../../includes/bootstrap.inc';
// Exit if we should be in a test environment but aren't.
if (!drupal_valid_test_ua()) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');

View File

@ -1195,24 +1195,3 @@ class TestEntityType extends ContentEntityType {
}
}
namespace Drupal\entity_test\Entity;
if (!function_exists('t')) {
function t($string, array $args = []) {
return strtr($string, $args);
}
}
namespace Drupal\Core\Entity;
if (!function_exists('t')) {
function t($string, array $args = []) {
return strtr($string, $args);
}
}

View File

@ -25,7 +25,6 @@ require_once __DIR__ . '/includes/utility.inc';
$request = Request::createFromGlobals();
// Manually resemble early bootstrap of DrupalKernel::boot().
require_once __DIR__ . '/includes/bootstrap.inc';
DrupalKernel::bootEnvironment();
try {

View File

@ -17,7 +17,6 @@ if (PHP_SAPI !== 'cli') {
// Bootstrap.
$autoloader = require __DIR__ . '/../../autoload.php';
require_once __DIR__ . '/../includes/bootstrap.inc';
$request = Request::createFromGlobals();
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();

View File

@ -17,7 +17,6 @@ if (PHP_SAPI !== 'cli') {
// Bootstrap.
$autoloader = require __DIR__ . '/../../autoload.php';
require_once __DIR__ . '/../includes/bootstrap.inc';
$request = Request::createFromGlobals();
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();

View File

@ -18,7 +18,6 @@ if (PHP_SAPI !== 'cli') {
// Bootstrap.
$autoloader = require __DIR__ . '/../../autoload.php';
require_once __DIR__ . '/../includes/bootstrap.inc';
$request = Request::createFromGlobals();
Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();

View File

@ -16,7 +16,6 @@ if (PHP_SAPI !== 'cli') {
}
$autoloader = require __DIR__ . '/../../autoload.php';
require_once __DIR__ . '/../includes/bootstrap.inc';
$request = Request::createFromGlobals();
Settings::initialize(DRUPAL_ROOT, DrupalKernel::findSitePath($request), $autoloader);

View File

@ -258,8 +258,6 @@ abstract class KernelTestBase extends TestCase implements ServiceProviderInterfa
$this->classLoader = require $this->root . '/autoload.php';
require_once $this->root . '/core/includes/bootstrap.inc';
// Set up virtual filesystem.
Database::addConnectionInfo('default', 'test-runner', $this->getDatabaseConnectionInfo()['default']);
$test_db = new TestDatabase();

View File

@ -60,7 +60,6 @@ class QuickStartTest extends TestCase {
}
// Get a lock and a valid site path.
$this->testDb = new TestDatabase();
include $this->root . '/core/includes/bootstrap.inc';
}
/**

View File

@ -59,13 +59,6 @@ class CronTest extends UnitTestCase {
protected function setUp(): void {
parent::setUp();
// @todo Remove in https://www.drupal.org/project/drupal/issues/2932518
//
// This line is currently needed so that watchdog_exception() is available
// when unit testing Drupal\Core\Cron and can safely be removed once that
// class no longer refers to it.
require_once $this->root . '/core/includes/bootstrap.inc';
// Construct a state object used for testing logger assertions.
$this->state = new State(new KeyValueMemoryFactory());

View File

@ -82,11 +82,6 @@ class DatabaseTest extends UnitTestCase {
*/
public function testFindDriverAutoloadDirectoryException($expected_message, $namespace, $include_tests) {
new Settings(['extension_discovery_scan_tests' => $include_tests]);
if ($include_tests === FALSE) {
// \Drupal\Core\Extension\ExtensionDiscovery::scan() needs
// drupal_valid_test_ua().
include $this->root . '/core/includes/bootstrap.inc';
}
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage($expected_message);
Database::findDriverAutoloadDirectory($namespace, $this->root);

View File

@ -1,17 +1,17 @@
<?php
namespace Drupal\Tests\Core\DrupalKernel {
namespace Drupal\Tests\Core\DrupalKernel;
use Drupal\Core\DrupalKernel;
use Drupal\Tests\UnitTestCase;
use org\bovigo\vfs\vfsStream;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\DrupalKernel;
use Drupal\Tests\UnitTestCase;
use org\bovigo\vfs\vfsStream;
use Symfony\Component\HttpFoundation\Request;
/**
/**
* @coversDefaultClass \Drupal\Core\DrupalKernel
* @group DrupalKernel
*/
class DrupalKernelTest extends UnitTestCase {
class DrupalKernelTest extends UnitTestCase {
/**
* Tests hostname validation with settings.
@ -136,12 +136,12 @@ EOD;
$this->assertEquals('sites/example', DrupalKernel::findSitePath($request, FALSE, $vfs_root->url('drupal_root')));
}
}
}
/**
/**
* A fake autoloader for testing
*/
class FakeAutoloader {
class FakeAutoloader {
/**
* Registers this instance as an autoloader.
@ -180,16 +180,4 @@ EOD;
return NULL;
}
}
}
namespace {
if (!function_exists('drupal_valid_test_ua')) {
function drupal_valid_test_ua($new_prefix = NULL) {
return FALSE;
}
}
}

View File

@ -23,7 +23,6 @@ if (PHP_SAPI !== 'cli') {
}
$autoloader = require_once 'autoload.php';
require_once 'core/includes/bootstrap.inc';
require_once 'core/includes/errors.inc';
define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);

View File

@ -44,8 +44,6 @@ class ExtensionSerializationTest extends UnitTestCase {
* @covers ::__wakeup
*/
public function testServiceAppRouteUsage() {
// The assumption of our test is that DRUPAL_ROOT is not defined.
$this->assertFalse(defined('DRUPAL_ROOT'), 'Constant DRUPAL_ROOT is defined.');
$container = new ContainerBuilder();
// Set a dummy container app.root to test against.
$container->setParameter('app.root', 'vfs://dummy_app_root');
@ -56,6 +54,14 @@ class ExtensionSerializationTest extends UnitTestCase {
$reflected_root = new \ReflectionProperty($extension, 'root');
$reflected_root->setAccessible(TRUE);
$this->assertEquals('vfs://dummy_app_root', $reflected_root->getValue($extension));
// Change the app root and test serializing and unserializing again.
$container->setParameter('app.root', 'vfs://dummy_app_root2');
\Drupal::setContainer($container);
$extension = unserialize(serialize($extension));
$reflected_root = new \ReflectionProperty($extension, 'root');
$reflected_root->setAccessible(TRUE);
$this->assertEquals('vfs://dummy_app_root2', $reflected_root->getValue($extension));
}
/**

View File

@ -111,13 +111,3 @@ class MachineNameTest extends UnitTestCase {
}
}
namespace Drupal\Core\Render\Element;
if (!function_exists('t')) {
function t($string, array $args = []) {
return strtr($string, $args);
}
}

View File

@ -77,9 +77,6 @@ trait TestRequirementsTrait {
* skipped. Callers should not catch this exception.
*/
private function checkModuleRequirements($root, array $annotations) {
// drupal_valid_ua() might not be loaded.
require_once $root . '/core/includes/bootstrap.inc';
// Make a list of required modules.
$required_modules = [];
foreach ($annotations as $requirement) {

View File

@ -16,7 +16,6 @@ $autoloader = require_once 'autoload.php';
// Disable garbage collection during test runs. Under certain circumstances the
// update path will create so many objects that garbage collection causes
// segmentation faults.
require_once 'core/includes/bootstrap.inc';
if (drupal_valid_test_ua()) {
gc_collect_cycles();
gc_disable();