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

| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 3042715-20.patch | 2.17 KB | krzysztof domański |
| #18 | interdiff-17-18.txt | 971 bytes | krzysztof domański |
| #18 | 3042715-18.patch | 3.12 KB | krzysztof domański |
| #17 | 3042715-17.patch | 2.17 KB | tr |
Comments
Comment #2
sergiu stici commentedHere is the patch, please review.
Comment #3
banoodle commentedI 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).
Comment #4
andralex commentedHere is a combined patch from two previous ones. I've reviewed deprecations and found 3 extra deprecations:
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
Comment #5
berdirThis also needs to update the .info.yml files to make the module comaptible with D9.
Comment #6
vsujeetkumar commentedComment #7
vsujeetkumar commentedAfter 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.
Comment #8
tr commentedReplacing 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.
Comment #9
vsujeetkumar commented@TR I have updated the patch only with entity_delete_multiple(), link() and config_export, Please review.
Comment #10
tr commented@vsujeetkumar: Inside of VoteStorage, you did this twice:
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);Comment #11
vsujeetkumar commented@TR done with the above change(#10), Please review.
Comment #12
tr commentedPatch applies and correctly replaces the deprecated functions. RTBC.
Comment #13
luke.leberGetting
Recoverable fatal error: Object of class Drupal\\Core\\Link could not be converted to stringon 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()?Comment #14
luke.leberComment #15
tr commented@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.)
Comment #16
krzysztof domańskiComment #17
tr commentedYeah, 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.
Comment #18
krzysztof domańskiComment #19
tr commentedPersonally 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.
Comment #20
krzysztof domańskiI agree with #19. Patch #17 looks good. I restore it.
Comment #21
krzysztof domańskiI created follow-up #3143178: HEAD of tests is broken in Drupal 9.
Comment #22
krzysztof domańskiAn additional problem #3143266: Error: Call to undefined method Drupal\Core\Entity\EntityDefinitionUpdateManager::applyUpdates() in votingapi_update_8301().
Comment #24
pifagor commented