diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index 04fac02..e836531 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -77,6 +77,16 @@ class Drupal { /** + * The current system version. + */ + const VERSION = '8.0-dev'; + + /** + * Core API compatibility. + */ + const CORE_COMPATIBILITY = '8.x'; + + /** * The currently active container object. * * @var \Symfony\Component\DependencyInjection\ContainerInterface diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index b9e5724..3ac1d89 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -464,7 +464,7 @@ protected function parseDependency($dependency) { // supports. Also, op is optional and defaults to equals. $p_op = '(?!=|==|=|<|<=|>|>=|<>)?'; // Core version is always optional: 8.x-2.x and 2.x is treated the same. - $p_core = '(?:' . preg_quote(DRUPAL_CORE_COMPATIBILITY) . '-)?'; + $p_core = '(?:' . preg_quote(\Drupal::CORE_COMPATIBILITY) . '-)?'; $p_major = '(?\d+)'; // By setting the minor version to x, branches can be matched. $p_minor = '(?(?:\d+|x)(?:-[A-Za-z]+\d+)?)'; diff --git a/core/lib/Drupal/Core/SystemListingInfo.php b/core/lib/Drupal/Core/SystemListingInfo.php index 3c34a5e..714365b 100644 --- a/core/lib/Drupal/Core/SystemListingInfo.php +++ b/core/lib/Drupal/Core/SystemListingInfo.php @@ -61,7 +61,7 @@ protected function process(array $files, array $files_to_add) { // If the module or theme is incompatible with Drupal core, remove it // from the array for the current search directory, so it is not // overwritten when merged with the $files array. - if (isset($info['core']) && $info['core'] != DRUPAL_CORE_COMPATIBILITY) { + if (isset($info['core']) && $info['core'] != \Drupal::CORE_COMPATIBILITY) { unset($files_to_add[$file_key]); } } diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php index 7b01ade..d3e474c 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php @@ -165,7 +165,7 @@ function testUserWithPermission() { $this->assertIdentical('settings', $ajax_commands[0]['command'], 'The first AJAX command is a settings command.'); // Second command: insert libraries into DOM. $this->assertIdentical('insert', $ajax_commands[1]['command'], 'The second AJAX command is an append command.'); - $command = new AppendCommand('body', '' . "\n"); + $command = new AppendCommand('body', '' . "\n"); $this->assertIdentical($command->render(), $ajax_commands[1], 'The append command contains the expected data.'); // Retrieving the form for this field should result in a 200 response, diff --git a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php index 6881092..8603f67 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php @@ -97,7 +97,7 @@ protected function resolveCacheMiss($offset) { $this->stringStorage->createString(array( 'source' => $offset, 'context' => $this->context, - 'version' => VERSION + 'version' => \Drupal::VERSION ))->addLocation('path', request_uri())->save(); $value = TRUE; } diff --git a/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php b/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php index 4860819..b1c5571 100644 --- a/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php +++ b/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php @@ -83,7 +83,7 @@ public function findTranslation(array $conditions) { if (!empty($values)) { $string = new TranslationString($values); - $this->checkVersion($string, VERSION); + $this->checkVersion($string, \Drupal::VERSION); $string->setStorage($this); return $string; } @@ -156,7 +156,7 @@ protected function updateLocation($string) { // This is a new location to add, take care not to duplicate. $this->connection->merge('locales_location', $this->options) ->key(array('sid' => $string->getId(), 'type' => $type, 'name' => $name)) - ->fields(array('version' => VERSION)) + ->fields(array('version' => \Drupal::VERSION)) ->execute(); $created = TRUE; } @@ -165,7 +165,7 @@ protected function updateLocation($string) { } if ($created) { // As we've set a new location, check string version too. - $this->checkVersion($string, VERSION); + $this->checkVersion($string, \Drupal::VERSION); } } } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php index 26b8080..caf19ce 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php @@ -73,7 +73,7 @@ function testStringCRUDAPI() { // Check version handling and updating. $this->assertEqual($source->version, 'none', 'String originally created without version.'); $string = $this->storage->findTranslation(array('lid' => $source->lid)); - $this->assertEqual($string->version, VERSION, 'Checked and updated string version to Drupal version.'); + $this->assertEqual($string->version, \Drupal::VERSION, 'Checked and updated string version to Drupal version.'); // Create translation and find it by lid and source. $langcode = 'es'; diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php index 32d8db7..ffe1253 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php @@ -222,10 +222,10 @@ protected function buildRow(array $modules, $module, $distribution) { $status = ''; // Check the core compatibility. - if ($module->info['core'] != DRUPAL_CORE_COMPATIBILITY) { + if ($module->info['core'] != \Drupal::CORE_COMPATIBILITY) { $compatible = FALSE; $status .= $this->t('This version is not compatible with Drupal !core_version and should be replaced.', array( - '!core_version' => DRUPAL_CORE_COMPATIBILITY, + '!core_version' => \Drupal::CORE_COMPATIBILITY, )); } @@ -259,7 +259,7 @@ protected function buildRow(array $modules, $module, $distribution) { $name = $modules[$dependency]->info['name']; // Disable the module's checkbox if it is incompatible with the // dependency's version. - if ($incompatible_version = drupal_check_incompatibility($version, str_replace(DRUPAL_CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) { + if ($incompatible_version = drupal_check_incompatibility($version, str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) { $row['#requires'][$dependency] = $this->t('@module (incompatible with version @version)', array( '@module' => $name . $incompatible_version, '@version' => $modules[$dependency]->info['version'], @@ -268,7 +268,7 @@ protected function buildRow(array $modules, $module, $distribution) { } // Disable the checkbox if the dependency is incompatible with this // version of Drupal core. - elseif ($modules[$dependency]->info['core'] != DRUPAL_CORE_COMPATIBILITY) { + elseif ($modules[$dependency]->info['core'] != \Drupal::CORE_COMPATIBILITY) { $row['#requires'][$dependency] = $this->t('@module (incompatible with this version of Drupal core)', array( '@module' => $name, )); diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/ParseInfoFileUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/ParseInfoFileUnitTest.php index c02e006..00acbaf 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/ParseInfoFileUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/ParseInfoFileUnitTest.php @@ -27,7 +27,7 @@ public static function getInfo() { function testParseInfoFile() { $info_values = drupal_parse_info_file(drupal_get_path('module', 'system') . '/tests/common_test_info.txt'); $this->assertEqual($info_values['simple_string'], 'A simple string', 'Simple string value was parsed correctly.', 'System'); - $this->assertEqual($info_values['version'], VERSION, 'Constant value was parsed correctly.', 'System'); + $this->assertEqual($info_values['version'], \Drupal::VERSION, 'Constant value was parsed correctly.', 'System'); $this->assertEqual($info_values['double_colon'], 'dummyClassName::', 'Value containing double-colon was parsed correctly.', 'System'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/AdminMetaTagTest.php b/core/modules/system/lib/Drupal/system/Tests/System/AdminMetaTagTest.php index 1b767e6..508ac2d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/AdminMetaTagTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/AdminMetaTagTest.php @@ -25,7 +25,7 @@ public static function getInfo() { * Verify that the meta tag HTML is generated correctly. */ public function testMetaTag() { - list($version, ) = explode('.', VERSION); + list($version, ) = explode('.', \Drupal::VERSION); $string = ''; $this->drupalGet('node'); $this->assertRaw($string, 'Fingerprinting meta tag generated correctly.', 'System'); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 49e87a0..0b1fd81 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -2277,7 +2277,7 @@ function hook_requirements($phase) { if ($phase == 'runtime') { $requirements['drupal'] = array( 'title' => t('Drupal'), - 'value' => VERSION, + 'value' => \Drupal::VERSION, 'severity' => REQUIREMENT_INFO ); } diff --git a/core/modules/update/lib/Drupal/update/Tests/UpdateCoreUnitTest.php b/core/modules/update/lib/Drupal/update/Tests/UpdateCoreUnitTest.php index ac26bd7..c682f99 100644 --- a/core/modules/update/lib/Drupal/update/Tests/UpdateCoreUnitTest.php +++ b/core/modules/update/lib/Drupal/update/Tests/UpdateCoreUnitTest.php @@ -45,20 +45,20 @@ function testUpdateBuildFetchUrl() { $project['info']['project status url'] = 'http://www.example.com'; $project['includes'] = array('module1' => 'Module 1', 'module2' => 'Module 2'); $site_key = ''; - $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY; + $expected = 'http://www.example.com/' . $project['name'] . '/' . \Drupal::CORE_COMPATIBILITY; $url = _update_build_fetch_url($project, $site_key); $this->assertEqual($url, $expected, "'$url' when no site_key provided should be '$expected'."); //For disabled projects it shouldn't add the site key either. $site_key = 'site_key'; $project['project_type'] = 'disabled'; - $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY; + $expected = 'http://www.example.com/' . $project['name'] . '/' . \Drupal::CORE_COMPATIBILITY; $url = _update_build_fetch_url($project, $site_key); $this->assertEqual($url, $expected, "'$url' should be '$expected' for disabled projects."); //for enabled projects, adding the site key $project['project_type'] = ''; - $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY; + $expected = 'http://www.example.com/' . $project['name'] . '/' . \Drupal::CORE_COMPATIBILITY; $expected .= '?site_key=site_key'; $expected .= '&list=' . rawurlencode('module1,module2'); $url = _update_build_fetch_url($project, $site_key); @@ -67,7 +67,7 @@ function testUpdateBuildFetchUrl() { // http://drupal.org/node/1481156 test incorrect logic when URL contains // a question mark. $project['info']['project status url'] = 'http://www.example.com/?project='; - $expected = 'http://www.example.com/?project=/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY; + $expected = 'http://www.example.com/?project=/' . $project['name'] . '/' . \Drupal::CORE_COMPATIBILITY; $expected .= '&site_key=site_key'; $expected .= '&list=' . rawurlencode('module1,module2'); $url = _update_build_fetch_url($project, $site_key); diff --git a/core/modules/views/lib/Drupal/views/Entity/View.php b/core/modules/views/lib/Drupal/views/Entity/View.php index e98ae01..82f93c4 100644 --- a/core/modules/views/lib/Drupal/views/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Entity/View.php @@ -79,7 +79,7 @@ class View extends ConfigEntityBase implements ViewStorageInterface { * * @var int */ - protected $core = DRUPAL_CORE_COMPATIBILITY; + protected $core = \Drupal::CORE_COMPATIBILITY; /** * Stores all display handlers of this view. diff --git a/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php index 94a2cf7..e94586f 100644 --- a/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/Block/ViewsBlockTest.php @@ -12,9 +12,6 @@ use Drupal\block\Plugin\views\display\Block; // @todo Remove this once the constant got converted. -if (!defined('DRUPAL_CORE_COMPATIBILITY')) { - define('DRUPAL_CORE_COMPATIBILITY', '8.x'); -} if (!defined('BLOCK_LABEL_VISIBLE')) { define('BLOCK_LABEL_VISIBLE', 'visible'); } diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index d57e28e..d426c6d 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -336,7 +336,7 @@ function hook_views_data_alter(array &$data) { function hook_views_query_substitutions(ViewExecutable $view) { // Example from views_views_query_substitutions(). return array( - '***CURRENT_VERSION***' => VERSION, + '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, '***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->id, '***DEFAULT_LANGUAGE***' => language_default()->id, diff --git a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php index 9b52116..172d6ef 100644 --- a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php +++ b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php @@ -13,10 +13,6 @@ use Drupal\views_ui\ViewUI; use Symfony\Component\DependencyInjection\Container; -if (!defined('DRUPAL_CORE_COMPATIBILITY')) { - define('DRUPAL_CORE_COMPATIBILITY', '8.x'); -} - /** * Tests the ViewUI class. *