web/modules/contrib/advanced_help/src/AdvancedHelpManager.php 136 Call to deprecated function file_scan_directory(). Deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\File\FileSystemInterface::scanDirectory() instead.

web/modules/contrib/advanced_help/src/Plugin/Search/AdvancedHelpSearch.php 218 Call to deprecated function search_index(). Deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\search\SearchIndex::index() instead.

web/modules/contrib/advanced_help/src/Plugin/Search/AdvancedHelpSearch.php 235 Call to deprecated function search_index_clear(). Deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\search\SearchIndex::clear() instead.

web/modules/contrib/advanced_help/src/Plugin/Search/AdvancedHelpSearch.php 242 Call to deprecated function search_mark_for_reindex(). Deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\search\SearchIndex::markForReindex() instead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mo_farhaz created an issue. See original summary.

mo_farhaz’s picture

Assigned: mo_farhaz » Unassigned
Status: Active » Needs review
FileSize
2.39 KB

please review.

mradcliffe’s picture

Title: Deprecated code report » Drupal 9 deprecated code report
Status: Needs review » Needs work
Issue tags: +Drupal 9 readiness

I would probably combine #3133661: Drupal 9 readiness and this issue together because the former shouldn't be committed until this module is Drupal 9 ready.

  1. +++ b/src/AdvancedHelpManager.php
    @@ -133,7 +134,7 @@ class AdvancedHelpManager extends DefaultPluginManager {
    +          $files = FileSystemInterface::scanDirectory("./$module_path",
    

    This will fail because you are trying to use an interface like a class.

    Instead, we should add the file_system service as a dependency for AdvancedHelpManager, and then we can typehint FileSystemInterface in the __construct method, and assign it to a protected class variable.

  2. +++ b/src/Plugin/Search/AdvancedHelpSearch.php
    @@ -215,7 +216,7 @@ class AdvancedHelpSearch extends SearchPluginBase implements AccessibleInterface
    +        SearchIndex::index($this->getPluginId(), $info['sid'], $language, file_get_contents($file));
    
    @@ -232,14 +233,14 @@ class AdvancedHelpSearch extends SearchPluginBase implements AccessibleInterface
    +    SearchIndex::clear($this->getPluginId());
    ...
    +    SearchIndex::markForReindex($this->getPluginId());
    

    This will fail because the SearchIndex class does not have static methods index, clear, or markForReindex. These are public methods that require an instance of the class to use.

    Similarly, we can add the search.index service as a dependency, and inject it in the __construct method, and then assign it to a protected class variable.

mradcliffe’s picture

I maintain freelinking, which depends on advanced_help and advanced_help_hint as test dependencies so at the moment my tests are failing in Drupal 9 without at least the patch in #3133661: Drupal 9 readiness.

Kristen Pol’s picture

kkalashnikov’s picture

Assigned: Unassigned » kkalashnikov
kkalashnikov’s picture

Assigned: kkalashnikov » Unassigned
jyotimishra-developer’s picture

Assigned: Unassigned » jyotimishra-developer
jyotimishra-developer’s picture

FileSize
5.33 KB

Changes asked in #3, has been addressed in the uploaded patch.
Thanks!!

jyotimishra-developer’s picture

Status: Needs work » Needs review
jyotimishra-developer’s picture

Assigned: jyotimishra-developer » Unassigned
jyotimishra-developer’s picture

please review the patch!!

gnuget’s picture

Status: Needs review » Needs work

Thanks all for the work on this.

I checked this and as soon as we commit this the module will stop working on Drupal 8.7.x which is not something that we want.

At least until Drupal 8.9/Drupal 9 be out we still want to support 8.7.x, so we need to add code for this, here how we can do it:

Preparing Drupal.org projects for Drupal 9

gnuget’s picture

Category: Bug report » Task
Priority: Minor » Normal
Status: Needs work » Needs review
FileSize
5.56 KB
6 KB

Ok, I worked on this today.

First of all, @jyotimishra123, @mo_farhaz , next time please TEST your changes before to uploading them.

I tested #9 and the file_system service wasn't even being injected and therefore it was triggering an error as soon as the user visits the advanced help page.

The same happened at #2, the changes aren't working at all.

The Drupal 9 Porting Weekend was created indeed to help Drupal to move forward but the event was also a big opportunity to learn and be mentored,

In case of doubt, you can ask for help, In Slack, IRC, or even here, I will be super happy to help but uploading things that are broken is a bit inconsiderate with the person that is going to review your changes.

Next time if I can help let me know :-)

====

Ok, new patch, I injected the file_system service added code to keep this module compatible with Drupal 8.7 and lower. I had to do a trick to inject the search.index service because it does not exists in drupal 8.7 and lower, I got the idea from this post.

Patch attached.

  • gnuget committed 5f12c28 on 8.x-1.x
    Issue #3133663 by gnuget, mradcliffe: Drupal 9 deprecated code report
    
gnuget’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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