Problem/Motivation

drupal-check results on commit hash:
source : [git] https://git.drupal.org/project/youtube a336716532f44d2b05cf02ce4b9d8a89698b9f63
source : http://cgit.drupalcode.org/youtube


 ------ -------------------------------------------------------- 
  Line   src/Tests/YouTubeTest.php                               
 ------ -------------------------------------------------------- 
  59     Call to deprecated method strtolower() of class         
         Drupal\Component\Utility\Unicode.                       
  61     Call to deprecated function entity_create().            
  69     Call to deprecated function entity_create().            
  76     Call to deprecated function entity_get_form_display().  
  83     Call to deprecated function entity_get_display().       
  123    Call to deprecated method strtolower() of class         
         Drupal\Component\Utility\Unicode.                       
  125    Call to deprecated function entity_create().            
  133    Call to deprecated function entity_create().            
  140    Call to deprecated function entity_get_form_display().  
  147    Call to deprecated function entity_get_display().       
 ------ -------------------------------------------------------- 

 ------ --------------------------------------------------- 
  Line   youtube.module                                     
 ------ --------------------------------------------------- 
  373    Call to deprecated function drupal_set_message().  
 ------ --------------------------------------------------- 

 [ERROR] Found 11 errors                                                    

 

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mcdwayne created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new3.54 KB

Here is the patch, please review.

vuil’s picture

Status: Needs review » Reviewed & tested by the community
amateichuk’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new5.29 KB

Patch based on #2 + replaced deprecated const

vuil’s picture

Status: Needs review » Reviewed & tested by the community

#4 make sense. It works for us.

  • guschilds committed c67bce2 on 8.x-1.x authored by Tolyan4ik
    Issue #3042827 by Sergiu Stici, Tolyan4ik, mcdwayne, vuil: Drupal 9...
guschilds’s picture

Status: Reviewed & tested by the community » Fixed

I've committed the patch to the 8.x-1.x branch and it will be a part of the next release. I also committed the addition of core_version_requirement to the module's info file, so at this point the module should be fully compatible with Drupal 9. Thanks everyone!

Status: Fixed » Closed (fixed)

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

asya_asina’s picture

This task is still relevant. I checked the code using drupal-check tools. And drupal-check showed follow results:

------ ------------------------------------------------------------------------------------------------
Line src/Tests/YouTubeTest.php
------ ------------------------------------------------------------------------------------------------
12 Class Drupal\youtube\Tests\YouTubeTest 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.
34 Call to method setUp() of 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 youtube.module
------ ---------------------------------------------------------------------
377 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.
------ ---------------------------------------------------------------------

guschilds’s picture

Status: Closed (fixed) » Active

Thanks for the heads up. Looks like both were deprecated in 8.8. Reopening.

tapaswini sahoo’s picture

Assigned: Unassigned » tapaswini sahoo
tapaswini sahoo’s picture

StatusFileSize
new1012 bytes

I already applied patch kindly review it.

tapaswini sahoo’s picture

Assigned: tapaswini sahoo » Unassigned
tapaswini sahoo’s picture

Status: Active » Needs review
guschilds’s picture

Status: Needs review » Needs work

Thanks for the patch tapaswini sahoo! I haven't yet applied and tested it, but one issue I'm seeing:

+  $files =FileSystemInterface::scanDirectory($youtube_thumb_uri, '/^.*\.(jpg|png)$/');

A space is missing after the =. This coding standard is discussed here and could also be detected using something like PHPCS.

Could you fix that? Thanks again!

tapaswini sahoo’s picture

Assigned: Unassigned » tapaswini sahoo
tapaswini sahoo’s picture

StatusFileSize
new1013 bytes
new1013 bytes
tapaswini sahoo’s picture

Assigned: tapaswini sahoo » Unassigned
Status: Needs work » Needs review
StatusFileSize
new451 bytes

Here i applied patch and interdiff also kindly review it please.

lisa.rae’s picture

Status: Needs review » Reviewed & tested by the community

Verified that this patch addressed Drupal 9 compatibility issues.

guschilds’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for the patches. While this may pass drupal-check, it looks like the switch from WebTestBase to BrowserTestBase may be more involved than this. See here: https://www.drupal.org/docs/8/testing/converting-d7-and-d8-simpletests-t...

Does more need to be done here to update these tests and organize them in the right files and directories? Or am I misunderstanding?

guschilds’s picture

Title: Drupal 9 Deprecated Code Report » Drupal 9 Readiness
kapilv’s picture

Status: Needs work » Needs review
StatusFileSize
new841 bytes
kapilv’s picture

Status: Needs review » Reviewed & tested by the community

  • guschilds committed bbfcb68 on 8.x-1.x
    Issue #3042827 by asya_asina, tapaswini sahoo, guschilds: Replaced...
guschilds’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for the patches. I have pushed a commit to replace file_scan_directory(). I gave myself authorship because the submitted patches did not contain valid code that worked, so I had to fix that.

There is still the outstanding issue of converting the WebTestBase test to a BrowserTestBase test. Multiple patches have been submitted that replace the class names, but as mentioned, I believe there is more to it than that, as outlined here: https://www.drupal.org/docs/8/testing/converting-d7-and-d8-simpletests-t...

If you're going to submit a patch or mark one as RTBC, please confirm that you've read that documentation and have gotten the BrowserTestBase test to run and pass.

  • guschilds committed 16460dc on 8.x-1.x
    Issue #3042827: Ported tests from deprecated WebTestBase to...
guschilds’s picture

Status: Needs work » Fixed

I was able to convert the tests to BrowserTestBase. Committed. That should cover everything at the moment.

Thanks again everyone. Marking as Fixed.

Status: Fixed » Closed (fixed)

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

ttnt’s picture

Hello,

Sorry to reopen but it seems there is still an issue in Drupal 9. It causes a WSOD on the settings page.

Uncaught PHP Exception Symfony\\Component\\DependencyInjection\\Exception\\ServiceNotFoundException: "You have requested a non-existent service "entity.manager"." at /core/lib/Drupal/Component/DependencyInjection/Container.php line 151

I found the reference here:
youtube/youtube.module:470: $entity_manager = \Drupal::service('entity.manager');
youtube/youtube.module:471: $field_map = $entity_manager->getFieldMap();

When I do:
- $entity_manager = \Drupal::service('entity.manager');
+ $entity_manager = \Drupal::service('entity_type.manager');

I get:
Error: Call to undefined method Drupal\\Core\\Entity\\EntityTypeManager::getFieldMap()

I'm not an expert here, but as the error changed, I assume that's the smoking gun for the WSOD :).

Thanks!

ttnt’s picture

This seems to have fixed it:
youtube.module line 470:

- $entity_manager = \Drupal::service('entity.manager');
+ $entity_manager = \Drupal::service('entity_field.manager');

No clue if this is the correct way of doing things?

guschilds’s picture

Hi herrzhull,

Good catch. Thanks for reporting it and for investigating and including a potential fix. Your hunch was right. If you look at the 8.x docs for EntityManager::getFieldMap, you'll see a comment about its (long ago) deprecation and how to find the fix. Sure enough, that method was just calling \Drupal::service('entity_field.manager')->getFieldMap();, so calling the same thing here was the way to go. I've committed this fix to the 8.x-1.x branch (b7c37d34).