EDIT: I removed mention of the deprecations that have already been fixed or should not be fixed. These are the remaining ones:

Problem/Motivation

drupal-check results on commit hash: 95f7cf2db229d5649a2787daf55375d7731e2f8e


 ------ -------------------------------------------------------
  Line   src/VoteStorage.php
 ------ -------------------------------------------------------
  40     Call to deprecated function entity_delete_multiple().
  79     Call to deprecated function entity_delete_multiple().
 ------ -------------------------------------------------------

 ------ -------------------------------------------------------------------------------
  Line   src/VoteTypeForm.php
 ------ -------------------------------------------------------------------------------
  147    Call to deprecated method link() of class Drupal\Core\Entity\EntityInterface.
 ------ -------------------------------------------------------------------------------

 [ERROR] Found 15 errors

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Arrow created an issue. See original summary.

sergiu stici’s picture

Status: Active » Needs review
StatusFileSize
new6.38 KB

Here is the patch, please review.

banoodle’s picture

Issue summary: View changes
StatusFileSize
new461 bytes
new127.36 KB

I reviewed this patch and it applied cleanly in my sandbox environment (PHP 7.1.16 and D8.6.15).

I re-ran drupal-check against the patched module, and it confirmed most deprecation errors are now resolved.

It did report that there was still one deprecated function: db_query in votingapi.install.

The attached patch replaces it with \Drupal::database()->query.

I validated this change, by first checking the config table in the database, then uninstalling the votingapi module and checking the table again (see attached).

andralex’s picture

Issue tags: +deprecated
StatusFileSize
new6.83 KB

Here is a combined patch from two previous ones. I've reviewed deprecations and found 3 extra deprecations:

 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  Line   src/Form/VoteTypeDeleteConfirm.php                                                                                                                                       
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  28     Parameter $query_factory of method Drupal\votingapi\Form\VoteTypeDeleteConfirm::__construct() has typehint with deprecated class Drupal\Core\Entity\Query\QueryFactory:  
         in drupal:8.3.0 and is removed from drupal:9.0.0. Use                                                                                                                    
         \Drupal\Core\Entity\EntityStorageInterface::getQuery() or                                                                                                                
         \Drupal\Core\Entity\EntityStorageInterface::getAggregateQuery() instead.                                                                                                 
 ------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------------------- 
  Line   src/Tests/VoteCreationTest.php                                                                         
 ------ ------------------------------------------------------------------------------------------------------- 
  14     Class Drupal\votingapi\Tests\VoteCreationTest 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.                            
  51     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   src/Tests/VoteTest.php                                                                         
 ------ ----------------------------------------------------------------------------------------------- 
  12     Class Drupal\votingapi\Tests\VoteTest 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.                    
 ------ ----------------------------------------------------------------------------------------------- 

There is two separate issues where they could be fixed: https://www.drupal.org/project/votingapi/issues/3112473 and https://www.drupal.org/project/votingapi/issues/3021997

berdir’s picture

Status: Needs review » Needs work

This also needs to update the .info.yml files to make the module comaptible with D9.

vsujeetkumar’s picture

Assigned: Unassigned » vsujeetkumar
vsujeetkumar’s picture

Assigned: vsujeetkumar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.64 KB

After run the test found below issue:

8x: Entity type "vote_type" is using config schema as a fallback for a missing `config_export` definition is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. See https://www.drupal.org/node/2949023.
2x in VoteCreationTest::testVoteCreationWithInvalidVoteType from Drupal\Tests\votingapi\Functional
2x in VoteTest::testVotes from Drupal\Tests\votingapi\Functional
2x in VoteTest::testVoteResults from Drupal\Tests\votingapi\Functional
2x in VoteTest::testAnonymousVoting from Drupal\Tests\votingapi\Functional

---------------------------------------------------------------------------------------

1) Drupal\Tests\votingapi\Functional\VoteTest::testVotes
Error: Call to a member function id() on string

/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:417
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:786
/var/www/html/drupal/web/modules/contrib/votingapi/src/VoteStorage.php:79
/var/www/html/drupal/web/modules/contrib/votingapi/votingapi.module:64
/var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:403
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:206
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:843
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:434
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:786
/var/www/html/drupal/web/modules/contrib/votingapi/tests/src/Functional/VoteTest.php:78

2) Drupal\Tests\votingapi\Functional\VoteTest::testVoteResults
Error: Call to a member function id() on string

/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:417
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:786
/var/www/html/drupal/web/modules/contrib/votingapi/src/VoteStorage.php:79
/var/www/html/drupal/web/modules/contrib/votingapi/votingapi.module:64
/var/www/html/drupal/web/core/lib/Drupal/Core/Extension/ModuleHandler.php:403
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:206
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:843
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:434
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:786
/var/www/html/drupal/web/modules/contrib/votingapi/tests/src/Functional/VoteTest.php:125

3) Drupal\Tests\votingapi\Functional\VoteTest::testAnonymousVoting
Error: Call to a member function id() on string

/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:417
/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:786
/var/www/html/drupal/web/modules/contrib/votingapi/src/VoteStorage.php:40
/var/www/html/drupal/web/modules/contrib/votingapi/tests/src/Functional/VoteTest.php:161

Patch create after fixed the issue. Please review.

tr’s picture

Status: Needs review » Needs work

Replacing the db_ calls is the subject of a much earlier issue, with a patch already provided: #2873325: Replaced deprecated query functions
That other patch is more correct because it handles injection of the database service, which the patch in #7 does not.
This task should be handled in that older issue and not here.
Please contribute to that older issue in order to get this fixed!

So the only things that need to be handled in this issue are entity_delete_multiple() and link() and config_export. Patch #7 has other changes which were not mentioned or discuss, like the removal of drush_log() - those changes should probably be separate issues.

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.29 KB
new3.64 KB

@TR I have updated the patch only with entity_delete_multiple(), link() and config_export, Please review.

tr’s picture

Issue summary: View changes
Status: Needs review » Needs work

@vsujeetkumar: Inside of VoteStorage, you did this twice:

+      $storage = \Drupal::entityTypeManager()->getStorage('vote');
+      $entities = $storage->loadMultiple($votes);

But we're inside the storage class - we don't need to go to the entity type manager to get a reference to the storage because we already have a reference - $this.

So these lines should instead be:
+ $entities = $this->loadMultiple($votes);

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new2.15 KB
new1.04 KB

@TR done with the above change(#10), Please review.

tr’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies and correctly replaces the deprecated functions. RTBC.

luke.leber’s picture

Getting Recoverable fatal error: Object of class Drupal\\Core\\Link could not be converted to string on 9.0.x-dev when saving a VoteType. Presumably due to the change of $type->link(...) to $type->toLink(...).

Does $type->toLink(...) need to be converted to a string here IE $type->toLink(...)->toString() ?

luke.leber’s picture

Status: Reviewed & tested by the community » Needs work
tr’s picture

Status: Needs work » Needs review
StatusFileSize
new2.16 KB

@Luke.Leber: Yes, you are correct. Here's a new patch. Please test to see if this fixes the problem.

(Our automated testing for this module needs some serious improvements - the tests should have failed because of this if we had even minimal test coverage for the VoteTypeForm.)

krzysztof domański’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
tr’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.17 KB

Yeah, the patch was broken by one of the commits made yesterday, #2873325: Replaced deprecated query functions.

Here's the re-roll against the current HEAD.

krzysztof domański’s picture

StatusFileSize
new3.12 KB
new971 bytes
1) Drupal\Tests\votingapi_tokens\Kernel\VoteTokenTest::testVoteTokens
Drupal\Core\Entity\EntityStorageException: The "path_alias" entity type does not exist.
tr’s picture

Personally I think #18 should be a separate issue, as it only involves the votingapi_tokens submodule. It will also require adding the path_alias module to the dependencies of votingapi_tokens.info.yml, BTW, as path_alias is optional in D9. Or the solution could be as simple as removing the path_alias assert, since this submodule really doesn't need to be testing path aliases at all. Regardless, this is not a simple use of a deprecated method, and is outside the scope of the current issue.

I don't think this should hold back making the main votingapi module compatible with D9.

BTW this is the ONLY issue preventing Voting API from being D9 compatible. Other modules, like Fivestar, depend on Voting API and can't be D9 compatible until Voting API is. Once this issue is committed THEN we can proceed to improve the submodules and any other minor things that are revealed by D9 testing. But D9 testing can't even be enabled until the deprecations in the Voting API module are fixed. See #3138493: Plan for Drupal 9.

krzysztof domański’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs followup
StatusFileSize
new2.17 KB

I agree with #19. Patch #17 looks good. I restore it.

krzysztof domański’s picture

pifagor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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