diff --git a/composer.json b/composer.json index b7e9683..292d13e 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "Drupal\\Driver": "drivers/lib/" }, "files": [ - "core/lib/Drupal.php" + "core/lib/Drupal.php", + "core/includes/bootstrap.inc" ] }, "config": { diff --git a/core/authorize.php b/core/authorize.php index ecb7e22..b3b4f4c 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -63,7 +63,6 @@ function authorize_access_allowed() { // *** Real work of the script begins here. *** -require_once __DIR__ . '/includes/bootstrap.inc'; require_once __DIR__ . '/includes/common.inc'; require_once __DIR__ . '/includes/file.inc'; require_once __DIR__ . '/includes/module.inc'; diff --git a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php index c9f3e7d..14fbc11 100644 --- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php @@ -37,8 +37,8 @@ protected function alterRoutes(RouteCollection $collection, $module) { foreach ($collection->all() as $route) { if ($not_allowed_variables = array_intersect($route->compile()->getVariables(), $special_variables)) { $placeholders = array('@variables' => implode(', ', $not_allowed_variables)); - drupal_set_message(String::format('The following variables are reserved names by drupal: @variables', $placeholders)); - watchdog('error', 'The following variables are reserved names by drupal: @variables', $placeholders); + $this->drupalSetMessage(String::format('The following variables are reserved names by drupal: @variables', $placeholders)); + $this->watchdog('error', 'The following variables are reserved names by drupal: @variables', $placeholders); return FALSE; } } @@ -60,4 +60,18 @@ public function onAlterRoutes(RouteBuildEvent $event) { return $this->alterRoutes($collection, $event->getProvider()); } + /** + * Wraps drupal_set_message(). + */ + public function drupalSetMessage($type = NULL, $message = '') { + drupal_set_message($type, $message); + } + + /** + * Wraps watchdog(). + */ + public function watchdog($type, $message, array $args = NULL) { + watchdog($type, $message, $args); + } + } diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index 6bcfd95..54b67cc 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -309,7 +309,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ // Update the {comment_entity_statistics} table prior to executing the hook. $storage_controller->updateEntityStatistics($this); if ($this->status->value == CommentInterface::PUBLISHED) { - module_invoke_all('comment_publish', $this); + \Drupal::moduleHandler()->invokeAll('comment_publish', array($this)); } } diff --git a/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php b/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php index d5f2eee..c80fd21 100644 --- a/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php +++ b/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentLockTest.php @@ -35,6 +35,8 @@ public function testLocks() { $container = new ContainerBuilder(); $container->set('current_user', $this->getMock('Drupal\Core\Session\AccountInterface')); $container->register('request', 'Symfony\Component\HttpFoundation\Request'); + $container->set('module_handler', $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface')); + $lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface'); $cid = 2; $lock_name = "comment:$cid:01.00/"; diff --git a/core/modules/statistics/statistics.php b/core/modules/statistics/statistics.php index ed132e8..573c387 100644 --- a/core/modules/statistics/statistics.php +++ b/core/modules/statistics/statistics.php @@ -10,7 +10,6 @@ // Load the Drupal bootstrap. require_once dirname(dirname(__DIR__)) . '/vendor/autoload.php'; -require_once dirname(dirname(__DIR__)) . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); if (\Drupal::config('statistics.settings')->get('count_content_views')) { diff --git a/core/modules/system/tests/http.php b/core/modules/system/tests/http.php index 662031f..93ced89 100644 --- a/core/modules/system/tests/http.php +++ b/core/modules/system/tests/http.php @@ -19,5 +19,4 @@ // Change current directory to the Drupal root. chdir('../../../..'); require_once dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php'; -require_once dirname(dirname(dirname(__DIR__))) . '/includes/bootstrap.inc'; drupal_handle_request(TRUE); diff --git a/core/modules/system/tests/https.php b/core/modules/system/tests/https.php index 247e6e5..f734556 100644 --- a/core/modules/system/tests/https.php +++ b/core/modules/system/tests/https.php @@ -21,5 +21,4 @@ // Change current directory to the Drupal root. chdir('../../../..'); require_once dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php'; -require_once dirname(dirname(dirname(__DIR__))) . '/includes/bootstrap.inc'; drupal_handle_request(TRUE); diff --git a/core/rebuild.php b/core/rebuild.php index 9ddf054..13d3d5e 100644 --- a/core/rebuild.php +++ b/core/rebuild.php @@ -16,7 +16,6 @@ chdir('..'); require_once __DIR__ . '/vendor/autoload.php'; -require_once __DIR__ . '/includes/bootstrap.inc'; require_once __DIR__ . '/includes/utility.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); diff --git a/core/scripts/password-hash.sh b/core/scripts/password-hash.sh index 8c6ebb1..3956a6a 100755 --- a/core/scripts/password-hash.sh +++ b/core/scripts/password-hash.sh @@ -80,7 +80,6 @@ $core = dirname(__DIR__); require_once $core . '/vendor/autoload.php'; -require_once $core . '/includes/bootstrap.inc'; // Bootstrap the code so we have the container. drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE); diff --git a/core/scripts/rebuild_token_calculator.sh b/core/scripts/rebuild_token_calculator.sh index 9b948b4..43ffdfa 100755 --- a/core/scripts/rebuild_token_calculator.sh +++ b/core/scripts/rebuild_token_calculator.sh @@ -8,7 +8,6 @@ */ require_once __DIR__ . '/../vendor/autoload.php'; -require_once dirname(__DIR__) . '/includes/bootstrap.inc'; use Drupal\Component\Utility\Crypt; diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 230afd6..8cfbac8 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -329,7 +329,6 @@ function simpletest_script_init($server_software) { } chdir(realpath(__DIR__ . '/../..')); - require_once dirname(__DIR__) . '/includes/bootstrap.inc'; } /** diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php index 0bb5006..b11aac2 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php @@ -5,7 +5,7 @@ * Contains \Drupal\Tests\Core\EventSubscriber\SpecialAttributesRouteSubscriberTest. */ -namespace Drupal\Tests\Core\EventSubscriber { +namespace Drupal\Tests\Core\EventSubscriber; use Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber; use Drupal\Core\Routing\RouteBuildEvent; @@ -24,7 +24,7 @@ class SpecialAttributesRouteSubscriberTest extends UnitTestCase { /** * The tested route subscriber. * - * @var \Drupal\Core\EventSubscriber\SpecialAttributesRouteSubscriber + * @var \Drupal\Tests\Core\EventSubscriber\TestSpecialAttributesRouteSubscriber */ protected $specialAttributesRouteSubscriber; @@ -42,7 +42,7 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - $this->specialAttributesRouteSubscriber = new SpecialAttributesRouteSubscriber(); + $this->specialAttributesRouteSubscriber = new TestSpecialAttributesRouteSubscriber(); } /** @@ -114,15 +114,13 @@ public function testOnRouteBuildingInvalidVariables(Route $route) { } -} +class TestSpecialAttributesRouteSubscriber extends SpecialAttributesRouteSubscriber { -namespace { - if (!function_exists('watchdog')) { - function watchdog($type, $message, array $args = NULL) { - } + public function drupalSetMessage($type = NULL, $message = '') { } - if (!function_exists('drupal_set_message')) { - function drupal_set_message($type = NULL, $message = '') { - } + + public function watchdog($type, $message, array $args = NULL) { } + } + diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php index c69a52f..97e2039 100644 --- a/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -82,7 +82,12 @@ function drupal_phpunit_register_extension_dirs(Composer\Autoload\ClassLoader $l drupal_phpunit_register_extension_dirs($loader, $dirs); // Look into removing this later. -define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']); +// @todo In a perfect world we would not use a bootstrapped drupal (simpletest) +// to run our phpunit tests, but we do, which will load bootstrap.inc +// so define a couple of more +if (!defined('REQUEST_TIME')) { + define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']); +} // Set sane locale settings, to ensure consistent string, dates, times and // numbers handling. diff --git a/core/update.php b/core/update.php index 075bfdb..60824d7 100644 --- a/core/update.php +++ b/core/update.php @@ -338,7 +338,6 @@ function update_check_requirements($skip_warnings = FALSE) { // We prepare a minimal bootstrap for the update requirements check to avoid // reaching the PHP memory limit. -require_once __DIR__ . '/includes/bootstrap.inc'; require_once __DIR__ . '/includes/update.inc'; require_once __DIR__ . '/includes/common.inc'; require_once __DIR__ . '/includes/file.inc'; diff --git a/core/vendor/composer/autoload_files.php b/core/vendor/composer/autoload_files.php index 2ebcd82..0330a92 100644 --- a/core/vendor/composer/autoload_files.php +++ b/core/vendor/composer/autoload_files.php @@ -8,4 +8,5 @@ return array( $vendorDir . '/kriswallsmith/assetic/src/functions.php', $baseDir . '/core/lib/Drupal.php', + $baseDir . '/core/includes/bootstrap.inc', ); diff --git a/index.php b/index.php index 2181fb3..fe20535 100644 --- a/index.php +++ b/index.php @@ -9,7 +9,6 @@ */ require_once __DIR__ . '/core/vendor/autoload.php'; -require_once __DIR__ . '/core/includes/bootstrap.inc'; try { drupal_handle_request();