diff --git a/core/includes/common.inc b/core/includes/common.inc index 0318002e1b..136c46eac1 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1249,13 +1249,13 @@ function drupal_check_incompatibility($v, $current_version) { * A space-separated string of extensions suitable for use by the file * validation system. * - * @deprecated in Drupal 8.7.x, will be removed before Drupal 9.0.0. Use - * \Drupal::service('plugin.manager.archiver')->getExtensions() instead. + * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use + * \Drupal\Core\Archiver\ArchiverManager::getExtensions() instead. * * @see https://www.drupal.org/node/2999951 */ function archiver_get_extensions() { - @trigger_error("archiver_get_extensions() is deprecated in Drupal 8.7.x and will be removed in Drupal 9.0.x. Use \Drupal::service('plugin.manager.archiver')->getExtensions() instead. See https://www.drupal.org/node/2999951."); + @trigger_error('archiver_get_extensions() is deprecated in Drupal 8.7.0 and will be removed in Drupal 9.0.0. Use \Drupal\Core\Archiver\ArchiverManager::getExtensions() instead. See https://www.drupal.org/node/2999951'); return \Drupal::service('plugin.manager.archiver')->getExtensions(); } @@ -1274,14 +1274,14 @@ function archiver_get_extensions() { * @throws \Exception * If a remote stream wrapper path was passed. * - * @deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Instead, + * @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Instead, * get plugin.manager.archiver service from container and call getInstance() * method on it. For example $archiver->getInstance(['filepath' => $file]); * * @see https://www.drupal.org/node/2999951 */ function archiver_get_archiver($file) { - @trigger_error('archiver_get_archiver() is deprecated in Drupal 8.7.x and will be removed in Drupal 9.0.x. Instead, get plugin.manager.archiver service from container and call getInstance() method on it. For example $archiver->getInstance(["filepath" => $file]); See https://www.drupal.org/node/2999951'); + @trigger_error('archiver_get_archiver() is deprecated in Drupal 8.7.0 and will be removed in Drupal 9.0.x. Instead, get plugin.manager.archiver service from container and call getInstance() method on it. For example $archiver->getInstance(["filepath" => $file]); See https://www.drupal.org/node/2999951'); // Archivers can only work on local paths $filepath = \Drupal::service('file_system')->realpath($file); if (!is_file($filepath)) { diff --git a/core/tests/Drupal/KernelTests/Core/Common/LegacyFunctionsTest.php b/core/tests/Drupal/KernelTests/Core/Common/LegacyFunctionsTest.php index b9bc2f709c..ad141340ff 100644 --- a/core/tests/Drupal/KernelTests/Core/Common/LegacyFunctionsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Common/LegacyFunctionsTest.php @@ -30,4 +30,25 @@ public function testDrupalSetTimeLimit() { drupal_set_time_limit(1000); } + /** + * @expectedDeprecation archiver_get_extensions() is deprecated in Drupal 8.7.0 and will be removed in Drupal 9.0.0. Use \Drupal\Core\Archiver\ArchiverManager::getExtensions() instead. See https://www.drupal.org/node/2999951 + */ + public function _testArchiverGetExtensions() { + $expected = \Drupal::service('plugin.manager.archiver')->getExtensions(); + $this->assertEquals($expected, archiver_get_extensions()); + } + + + /** + * @expectedDeprecation archiver_get_archiver() is deprecated in Drupal 8.7.0 and will be removed in Drupal 9.0.x. Instead, get plugin.manager.archiver service from container and call getInstance() method on it. For example $archiver->getInstance(["filepath" => $file]); See https://www.drupal.org/node/2999951 + */ + public function testArchiverGetArchiver() { + $file = DRUPAL_ROOT . 'core/modules/update/tests/aaa_update_test.tar.gz'; + $expected = \Drupal::service('plugin.manager.archiver')->getInstance([ + 'filepath' => $file, + ]); + $actual = archiver_get_archiver($file); + $this->assertEquals($expected, $actual); + } + }