Problem/Motivation

There are several issues we need to have a look at in order to make it Drupal 9 ready:

------ -----------------------------------------------------------------
Line sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php
------ -----------------------------------------------------------------
101 Call to deprecated function entity_get_form_display():
in drupal:8.8.0 and is removed from drupal:9.0.0. Use
EntityDisplayRepositoryInterface::getFormDisplay() instead.
------ -----------------------------------------------------------------

------ -------------------------------------------------------------------------
Line sources/content/tests/src/Functional/ContentTmgmtEntitySourceUiTest.php
------ -------------------------------------------------------------------------
1063 Call to deprecated function entity_get_form_display():
in drupal:8.8.0 and is removed from drupal:9.0.0. Use
EntityDisplayRepositoryInterface::getFormDisplay() instead.
------ -------------------------------------------------------------------------

------ ------------------------------------------------------------------
Line sources/content/tests/src/Kernel/ContentEntitySourceUnitTest.php
------ ------------------------------------------------------------------
94 Call to deprecated function file_unmanaged_copy():
in drupal:8.7.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::copy().
------ ------------------------------------------------------------------

------ -------------------------------------------------------------------------------------------------------------------
Line sources/locale/tests/src/Functional/LocaleSourceUiTest.php
------ -------------------------------------------------------------------------------------------------------------------
30 Call to deprecated constant FILE_EXISTS_REPLACE: Deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
\Drupal\Core\File\FileSystemInterface::EXISTS_REPLACE.
30 Call to deprecated function file_unmanaged_copy():
in drupal:8.7.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::copy().
------ -------------------------------------------------------------------------------------------------------------------

------ -------------------------------------------------------------------------------------------------------------------
Line sources/locale/tests/src/Kernel/LocaleSourceTest.php
------ -------------------------------------------------------------------------------------------------------------------
33 Call to deprecated constant FILE_EXISTS_REPLACE: Deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
\Drupal\Core\File\FileSystemInterface::EXISTS_REPLACE.
33 Call to deprecated function file_unmanaged_copy():
in drupal:8.7.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::copy().
106 Call to deprecated function db_query():
in drupal:8.0.0 and is removed from drupal:9.0.0. Instead,
get a database connection injected into your service from the container
and call query() on it. For example,
------ -------------------------------------------------------------------------------------------------------------------

------ -----------------------------------------------------------------------------------------------------------------------------------------------
Line src/Entity/Job.php
------ -----------------------------------------------------------------------------------------------------------------------------------------------
254 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
459 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
------ -----------------------------------------------------------------------------------------------------------------------------------------------

------ -----------------------------------------------------------------------------------------------------------------------------------------------
Line src/Entity/JobItem.php
------ -----------------------------------------------------------------------------------------------------------------------------------------------
682 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
931 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
------ -----------------------------------------------------------------------------------------------------------------------------------------------

------ ----------------------------------------------------------------------------------------------------
Line src/Tests/EntityTestBase.php
------ ----------------------------------------------------------------------------------------------------
23 Class Drupal\tmgmt\Tests\EntityTestBase extends deprecated class Drupal\tmgmt\Tests\TMGMTTestBase.
------ ----------------------------------------------------------------------------------------------------

------ ------------------------------------------------------------------------------------------------
Line src/Tests/TMGMTTestBase.php
------ ------------------------------------------------------------------------------------------------
17 Class Drupal\tmgmt\Tests\TMGMTTestBase extends deprecated class Drupal\simpletest\WebTestBase:
in drupal:8.8.0 and is removed from drupal:9.0.0. Instead,
use \Drupal\Tests\BrowserTestBase. See https://www.drupal.org/node/3030340.
------ ------------------------------------------------------------------------------------------------

------ ----------------------------------------------------
Line tests/src/Functional/TMGMTUiReviewTest.php
------ ----------------------------------------------------
49 Call to deprecated function file_unmanaged_copy():
in drupal:8.7.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::copy().
------ ----------------------------------------------------

------ ----------------------------------------------------------
Line tests/src/FunctionalJavascript/TMGMTUiJavascriptTest.php
------ ----------------------------------------------------------
78 Call to deprecated function file_unmanaged_copy():
in drupal:8.7.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::copy().
------ ----------------------------------------------------------

------ -----------------------------------------------------------------------------------------------------------------------------------------------
Line tests/src/Kernel/CrudTest.php
------ -----------------------------------------------------------------------------------------------------------------------------------------------
266 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
280 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
286 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
291 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
308 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
313 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
330 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
335 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
369 Call to deprecated constant REQUEST_TIME: Deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal::time()->getRequestTime();
------ -----------------------------------------------------------------------------------------------------------------------------------------------

------ -----------------------------------------------------------------
Line tmgmt.module
------ -----------------------------------------------------------------
804 Call to deprecated function tmgmt_redirect_queue_set():
Deprecated in 8.x-1.x, use \Drupal\tmgmt\JobQueue::startQueue()
instead.
809 Call to deprecated function tmgmt_redirect_queue_dequeue():
Deprecated in 8.x-1.x, use \Drupal\tmgmt\JobQueue::getNextJob()
instead.
809 Call to deprecated function tmgmt_redirect_queue_destination():
Deprecated in 8.x-1.x, use
\Drupal\tmgmt\JobQueue::getDestination() instead.
------ -----------------------------------------------------------------

------ -----------------------------------------------------------------------------------------------------------------------
Line translators/tmgmt_file/src/Plugin/tmgmt/Translator/FileTranslator.php
------ -----------------------------------------------------------------------------------------------------------------------
40 Call to deprecated constant FILE_CREATE_DIRECTORY: Deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
\Drupal\Core\File\FileSystemInterface::CREATE_DIRECTORY.
40 Call to deprecated constant FILE_MODIFY_PERMISSIONS: Deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
\Drupal\Core\File\FileSystemInterface::MODIFY_PERMISSIONS.
40 Call to deprecated function file_prepare_directory():
in drupal:8.7.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::prepareDirectory().
41 Call to deprecated constant FILE_EXISTS_REPLACE: Deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
\Drupal\Core\File\FileSystemInterface::EXISTS_REPLACE.
------ -----------------------------------------------------------------------------------------------------------------------

------ ---------------------------------------------------------------------
Line translators/tmgmt_file/tmgmt_file.drush.inc
------ ---------------------------------------------------------------------
46 Call to deprecated function drush_log().
47 Call to deprecated function file_scan_directory():
in drupal:8.8.0 and is removed from drupal:9.0.0.
Use \Drupal\Core\File\FileSystemInterface::scanDirectory() instead.
61 Call to deprecated function drush_log().
66 Call to deprecated function drush_log().
73 Call to deprecated function drush_log().
76 Call to deprecated function drush_log().
------ ---------------------------------------------------------------------

------ -------------------------------------------------------------
Line translators/tmgmt_local/tmgmt_local.install
------ -------------------------------------------------------------
13 Call to deprecated function entity_get_form_display():
in drupal:8.8.0 and is removed from drupal:9.0.0. Use
EntityDisplayRepositoryInterface::getFormDisplay() instead.
19 Call to deprecated function entity_get_form_display():
in drupal:8.8.0 and is removed from drupal:9.0.0. Use
EntityDisplayRepositoryInterface::getFormDisplay() instead.
------ -------------------------------------------------------------

[ERROR] Found 40 errors

Comments

sasanikolic created an issue. See original summary.

sasanikolic’s picture

StatusFileSize
new34.18 KB

Here is the patch with the fixes for the warnings mentioned above. All should be fixed except the TMGMT base tests.

sasanikolic’s picture

Status: Active » Needs review
berdir’s picture

Status: Needs review » Needs work
  1. +++ b/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php
    @@ -98,7 +99,7 @@ class ContentEntitySource extends SourcePluginBase implements SourcePreviewInter
         $data = $this->extractTranslatableData($translation);
    ...
    +    $entity_form_display = EntityDisplayRepositoryInterface::getFormDisplay($job_item->getItemType(), $entity->bundle(), 'default');
         uksort($data, function ($a, $b) use ($entity_form_display) {
           $a_weight = NULL;
    

    this is a service.

  2. +++ b/sources/content/tests/src/Functional/ContentTmgmtEntitySourceUiTest.php
    @@ -1060,7 +1061,7 @@ class ContentTmgmtEntitySourceUiTest extends TMGMTTestBase {
     
    -    entity_get_form_display('node', 'article1', 'default')
    +    EntityDisplayRepositoryInterface::getFormDisplay('node', 'article1', 'default')
           ->setComponent('body', array(
    

    same.

  3. +++ b/sources/content/tests/src/Kernel/ContentEntitySourceUnitTest.php
    @@ -91,7 +92,7 @@ class ContentEntitySourceUnitTest extends ContentEntityTestBase {
           'label' => $this->image_label = $this->randomMachineName(),
         ))->save();
    -    file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg');
    +    FileSystemInterface::copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg');
         $this->image = File::create([
    

    and smae.

  4. +++ b/tmgmt.module
    @@ -1119,13 +1120,13 @@ function tmgmt_job_checkout_and_redirect(FormStateInterface $form_state, array $
           // redirect instead.
    -      tmgmt_redirect_queue_set($redirects, $request->query->get('destination'));
    +      JobQueue::startQueue($redirects, $request->query->get('destination'));
           $request->query->remove('destination');
         }
         else {
    -      tmgmt_redirect_queue_set($redirects, Url::fromRoute('<current>')->getInternalPath());
    +      JobQueue::startQueue($redirects, Url::fromRoute('<current>')->getInternalPath());
         }
    -    $form_state->setRedirectUrl(Url::fromUri('base:' . tmgmt_redirect_queue_dequeue()));
    +    $form_state->setRedirectUrl(Url::fromUri('base:' . JobQueue::getNextJob()));
    

    don't change, they must call the old functions, as they themself are also part of the old deprecated API

  5. +++ b/translators/tmgmt_file/src/Commands/TmgmtFileCommands.php
    @@ -0,0 +1,81 @@
    +
    +    if (is_dir($name)) {
    +      $this->logger()->warning(dt('Scanning dir @dir.', array('@dir' => $name)), 'success');
    +      $files = FileSystemInterface::scanDirectory($name, '/.*\.xlf$/');
    +      if (empty($files)) {
    +        drush_set_error(dt('No files found to import in @name.', array('@name' => $name)));
    +      }
    +    }
    

    all drush_ functions in here should probably be updated to a new thing.

  6. +++ b/translators/tmgmt_file/src/Plugin/tmgmt/Translator/FileTranslator.php
    @@ -37,8 +38,8 @@ class FileTranslator extends TranslatorPluginBase {
         $dirname = dirname($path);
    -    if (file_prepare_directory($dirname, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
    -      $file = file_save_data($export->export($job), $path, FILE_EXISTS_REPLACE);
    +    if (FileSystemInterface::prepareDirectory($dirname, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS)) {
    +      $file = file_save_data($export->export($job), $path, FileSystemInterface::EXISTS_REPLACE);
    

    use the service.

  7. +++ b/translators/tmgmt_file/tmgmt_file.drush.inc
    @@ -43,8 +45,8 @@ function drush_tmgmt_file_tmgmt_translate_import($name = NULL) {
       if (is_dir($name)) {
    -    drush_log(dt('Scanning dir @dir.', array('@dir' => $name)), 'success');
    -    $files = file_scan_directory($name, '/.*\.xlf$/');
    +    $this->logger()->warning(dt('Scanning dir @dir.', array('@dir' => $name)), 'success');
    +    $files = FileSystemInterface::scanDirectory($name, '/.*\.xlf$/');
         if (empty($files)) {
           drush_set_error(dt('No files found to import in @name.', array('@name' => $name)));
         }
    

    no changes to drush_* in here.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new32.36 KB
new11.85 KB

Made the code changes mentioned above and tested with exporting and importing an xliff document with the new drush command. Should work better now.

Also, applied the patch from https://www.drupal.org/files/issues/2018-12-17/3020957-2.patch here, so let's see what the testbot says.

sasanikolic’s picture

sasanikolic’s picture

This should fix lots of test fails.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/modules/demo/tmgmt_demo.install
    @@ -15,7 +15,7 @@ use Drupal\user\RoleInterface;
     function tmgmt_demo_install() {
       // Ensure the translation fields are created in the database.
    -  \Drupal::service('entity.definition_update_manager')->applyUpdates();
    +  \Drupal::service('entity.definition_update_manager')->getChangeList();
    

    just remove this, getChangeList() would just return a list of changes to do, either function doesn't actually do anything anymore. So if it works then it is safe to remove.

  2. +++ b/tests/src/Kernel/PluginsTest.php
    @@ -9,7 +9,8 @@ use Drupal\tmgmt\Entity\Job;
      */
    -class PluginsTest extends TMGMTKernelTestBase {
    +class
    +PluginsTest extends TMGMTKernelTestBase {
    

    accidental newline.

  3. +++ b/translators/tmgmt_file/tmgmt_file.drush.inc
    @@ -43,8 +45,8 @@ function drush_tmgmt_file_tmgmt_translate_import($name = NULL) {
     
       if (is_dir($name)) {
    -    drush_log(dt('Scanning dir @dir.', array('@dir' => $name)), 'success');
    -    $files = file_scan_directory($name, '/.*\.xlf$/');
    +    $this->logger()->warning(dt('Scanning dir @dir.', array('@dir' => $name)), 'success');
    +    $files = FileSystemInterface::scanDirectory($name, '/.*\.xlf$/');
         if (empty($files)) {
    

    stil some incorrect changes in here.

  4. +++ b/translators/tmgmt_local/tmgmt_local.install
    @@ -1,5 +1,7 @@
     
    +use \Drupal\Core\Entity\EntityDisplayRepositoryInterface;
    

    the use isn't needed anymore.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new42.08 KB
new7.37 KB

Some more test fixes.

sasanikolic’s picture

This patch should fix TMGMTUiJavascriptTest and LocalTranslatorTest test fails.

sasanikolic’s picture

And here is the fix for the ConfigSourceUnitTest warning. Others seem like issues with other modules @Berdir?

sasanikolic’s picture

I removed the drupalci.yml in this patch. Let's see if tests pass now.

sasanikolic’s picture

As discussed with @Berdir, removing the lines that causes the LocaleSourceUiTest and LocaleSourceTest tests to fail. The issue was with file_unamanaged_copy function that logged the error, but we never checked for that before.

berdir’s picture

Assigned: sasanikolic » Unassigned
Status: Needs review » Reviewed & tested by the community

I think this is ready now, will commit it in march or so.

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

  • Berdir committed 52a3ff2 on 8.x-1.x authored by sasanikolic
    Issue #3108499 by sasanikolic: Drupal 9 compatibility update
    

  • Berdir committed 36fe9b7 on 8.x-1.x authored by sasanikolic
    Issue #3108499 by sasanikolic, Berdir: Drupal 9 compatibility update
    

  • Berdir committed 3c08660 on 8.x-1.x authored by sasanikolic
    Issue #3108499 by sasanikolic, Berdir: Require path_alias in kernel test
    

  • Berdir committed f5f6eab on 8.x-1.x
    Issue #3108499 by sasanikolic, Berdir: Fix ConfigSourceWebformTest
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.