Problem/Motivation

The test bot fails to install freelinking because the info.yml file does not contain the new core_version_requirement key. As well, the freelinking_prepopulate module will need to be updated, but will not work until prepopulate is ready for Drupal 9.0.x as well.

Current tests are not passing for Drupal 8.9.x - https://www.drupal.org/pift-ci-job/1446496.

Proposed resolution

First set the key, and set the value to ^8 || ^9. Then see what else fails. We should not need to make any major architectural changes at the moment, but only aim to fix deprecation failures that pop up.

Deprecation Fix Can Fix?
Usage of deprecated trait Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait in class Drupal\Tests\freelinking_prepopulate\Functional\FreelinkingPrepopulateTest Use \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait instead Yes
Interface Drupal\freelinking\Plugin\FreelinkingPluginInterface extends deprecated interface Drupal\Component\Plugin\ConfigurablePluginInterface Use \Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait instead Yes
Call to deprecated function file_unmanaged_copy() Use \Drupal\Core\File\FileSystemInterface::copy() Yes

Ignore any test failures of freelinking_prepopulate.

Remaining tasks

Write an initial patch, and make sure that the tests run on Drupal 9 and Drupal 8.

Comments

mradcliffe created an issue. See original summary.

mradcliffe’s picture

Issue summary: View changes

Added a note about current test run on 8.9.x. I've seen this test fail before locally, but not on the test bot. There could be some new thing that the test suite needs to do in order to save nodes.

fazni’s picture

fazni’s picture

Status: Active » Needs review
fazni’s picture

Status: Needs review » Needs work
gayathri j’s picture

StatusFileSize
new410 bytes

Added core_version_requirement key in info.yml file for freelinking module please review.

gayathri j’s picture

StatusFileSize
new1017 bytes

Please ignore #6 i created new patch.

mradcliffe’s picture

Status: Needs work » Needs review
Issue tags: -Novice
StatusFileSize
new1.74 KB
new642 bytes

Thank you for all the patches, @fazni! This will help move this forward a bit. @J.Gayathri, the patch in #7 seems to be the same in #3. Thank you for adding it though as that helps confirm @fazni's work.

I've seen this error before and now that I've taken a closer look it's probably due to Content Translation changes in Drupal 8. Here's a patch that might help fix the test failure, but it will probably fail in another area. It will get tricky after this because of the deprecation in 8.7.0 that cannot be removed until 8.7 is out of support. So I'm going to remove the novice tag for now. That doesn't mean that someone couldn't continue on working on it.

mradcliffe’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Novice

Okay, it was only my local environment. Running drupal-check on the code base I found the following 3 deprecations that need to be addressed.

I think this is novice again. The next step is to fix the deprecations. The most complex one is going to be ConfigurableInterface. The new suggestion to implement both interfaces is going to be important here and that should be the route to take to implement

-enzo-’s picture

StatusFileSize
new2.14 KB
new4.27 KB

Hi folks.

Attached you could find a patch to address the last three remaining issues.

mradcliffe’s picture

Thank you for the new patch, @-enzo-!

It looks like the patch is failing tests. See below. I guess, don't worry about testing on 9.0.x branch for now as prepopulate module doesn't have the core_version_requirement key either.

+++ b/tests/src/Functional/FreelinkingFilterTest.php
@@ -29,7 +30,7 @@ class FreelinkingFilterTest extends FreelinkingBrowserTestBase {
+    FileSystemInterface::copy($image_path, 'public://logo.png');

We won't be able to use this method statically and this is being called on an interface.

Instead we need to get the file_system service, \Drupal::service('file_system'), which is an instance of FileSystem that implements FileSystemInterface.

Then we can call the copy method using the -> instance operator rather than the static operator.

-enzo-’s picture

StatusFileSize
new4.07 KB
new844 bytes

Hi @mradcliffe

Thanks for the review

Attached you can find a new version with his interdiff

mradcliffe’s picture

The tests here will probably fail so I won't flip the issue to Needs review, but generally when uploading a new patch, remember to change the status to Needs review so that the drupal.org testing infrastructure will automatically test the patch. If the issue is in a different status, then it won't be tested.

+++ b/tests/src/Functional/FreelinkingFilterTest.php
@@ -29,7 +29,7 @@ class FreelinkingFilterTest extends FreelinkingBrowserTestBase {
-    file_unmanaged_copy($image_path, 'public://logo.png');
+    $filesystem->copy($image_path, 'public://logo.png');

Remember, we still need to instantiate the service.

If we take a look at the Change Record for file_unmanaged_copy we should be able to use \Drupal::service('file_system')->copy()

You have the right idea in your initial work with the interface, but we can't call a method on an interface.

-enzo-’s picture

HI @mradcliffe

Thanks for the revision, in the patch the instantiation is not visible, but in the code was already there

    /** @var \Drupal\Core\File\FileSystemInterface $filesystem */
    $filesystem = $this->container->get('file_system');

You can see the code at gitlab https://git.drupalcode.org/project/freelinking/blob/8.x-3.x/tests/src/Fu... , this is before the patch

mradcliffe’s picture

Status: Needs work » Needs review

Thank you for pointing that out, @-enzo-.

I changed the issue status to Needs review so that your latest patch will run through the tests for 8.9.x.

mradcliffe’s picture

Status: Needs review » Needs work
+++ b/tests/src/Functional/FreelinkingFilterTest.php
@@ -29,7 +29,7 @@ class FreelinkingFilterTest extends FreelinkingBrowserTestBase {
     $root_path = $_SERVER['DOCUMENT_ROOT'];
     $image_path = $root_path . '/core/themes/bartik/logo.png';
-    file_unmanaged_copy($image_path, 'public://logo.png');
+    $filesystem->copy($image_path, 'public://logo.png');

At some point logo.png was removed from bartik. It looks like logo.svg has existed since 2015 so that seems like it's safe.

I also found that $root_path is an empty string when I ran locally so maybe just try a relative path: $image_path = 'core/themes/bartik/logo.svg'; and remove $root_path. And update the assertions.

-enzo-’s picture

StatusFileSize
new5.52 KB
new1.94 KB

Attached you could find the patch and interdiff with the changes suggested, thank you for your revision

mradcliffe’s picture

Status: Needs work » Needs review

Changing to Needs review.

  • mradcliffe committed 0010113 on 8.x-3.x authored by -enzo-
    Issue #3089759 by -enzo-, J.Gayathri, fazni, mradcliffe: Updates...
mradcliffe’s picture

Status: Needs review » Fixed

Thank you, @-enzo-, @J.Gayathri, @fazni for working on this.

I have committed the patch to 8.x-3.x.

gayathri j’s picture

It's good to see this feature moving forward.
Thanks all.

Status: Fixed » Closed (fixed)

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