Remove any deprecated code for Drupal 9 readiness.
drupal-check results:
5/5 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line nodeaccess.module
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
72 Call to deprecated constant DRUPAL_ANONYMOUS_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
\Drupal\user\RoleInterface::ANONYMOUS_ID instead.
72 Call to deprecated constant DRUPAL_AUTHENTICATED_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::AUTHENTICATED_ROLE or
\Drupal\user\RoleInterface::AUTHENTICATED_ID instead.
75 Call to deprecated constant DRUPAL_ANONYMOUS_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
\Drupal\user\RoleInterface::ANONYMOUS_ID instead.
76 Call to deprecated constant DRUPAL_ANONYMOUS_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
\Drupal\user\RoleInterface::ANONYMOUS_ID instead.
80 Call to deprecated constant DRUPAL_AUTHENTICATED_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::AUTHENTICATED_ROLE or
\Drupal\user\RoleInterface::AUTHENTICATED_ID instead.
81 Call to deprecated constant DRUPAL_AUTHENTICATED_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::AUTHENTICATED_ROLE or
\Drupal\user\RoleInterface::AUTHENTICATED_ID instead.
233 Call to deprecated constant DRUPAL_ANONYMOUS_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
\Drupal\user\RoleInterface::ANONYMOUS_ID instead.
233 Call to deprecated constant DRUPAL_AUTHENTICATED_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::AUTHENTICATED_ROLE or
\Drupal\user\RoleInterface::AUTHENTICATED_ID instead.
234 Call to deprecated constant DRUPAL_ANONYMOUS_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
\Drupal\user\RoleInterface::ANONYMOUS_ID instead.
235 Call to deprecated constant DRUPAL_AUTHENTICATED_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::AUTHENTICATED_ROLE or
\Drupal\user\RoleInterface::AUTHENTICATED_ID instead.
236 Call to deprecated constant DRUPAL_ANONYMOUS_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
\Drupal\user\RoleInterface::ANONYMOUS_ID instead.
241 Call to deprecated constant DRUPAL_AUTHENTICATED_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::AUTHENTICATED_ROLE or
\Drupal\user\RoleInterface::AUTHENTICATED_ID instead.
272 Call to deprecated constant DRUPAL_ANONYMOUS_RID: Deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use Drupal\Core\Session\AccountInterface::ANONYMOUS_ROLE or
\Drupal\user\RoleInterface::ANONYMOUS_ID instead.
------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------
Line src/Form/GrantsForm.php
------ -------------------------------------------------------------------------
44 Call to deprecated function db_query():
as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
a database connection injected into your service from the container and
call query() on it. For example,
69 Call to deprecated function db_query():
as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
a database connection injected into your service from the container and
call query() on it. For example,
99 Call to deprecated function db_query():
as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
a database connection injected into your service from the container and
call query() on it. For example,
333 Call to deprecated function db_insert():
as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get
a database connection injected into your service from the container and
call insert() on it. For example,
345 Call to deprecated function drupal_set_message():
in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
------ -------------------------------------------------------------------------
[ERROR] Found 18 errors
Comments
Comment #2
Coops_Comment #3
alisonAdd drupal-check results.
Comment #4
alisonHi @Coops_ -- thank you so very much for doing this check and submitting a patch!
I'd like to split out the changes related to D9 deprecated code from the changes that aren't -- after skimming the patch, my impression is that the changes that aren't specifically for addressing D9 deprecated code are all to fix coding standards issues, is that accurate, or? If that's accurate, if that's all the other changes are, could you please create a separate issue with the coding standards changes, and submit a new version of this patch with just the D9 deprecated code fixes?
Please lmk if you have any questions, or if I've misunderstood your patch. Thanks!
Comment #5
swatichouhan012 commented@alisonjo315 Here is new patch to fix deprecated code, kindly review.
Comment #6
alisonThank you @swatichouhan012, and thanks for including the updated report!
Pardon my ignorance -- does it need a replacement for services.yml, i.e. nodeaccess.services.yml, or?
(interdiff attached, for "posterity or whatever" 😁)
Comment #7
john cook commentedI've tried to have a look at this patch but it currently doesn't apply because of some work done in
Node access roles will save, but per user still need hammering. Committing tonight's work, so this patch needs a reroll.Because of this, I've changed the status back to Needs work as well as adding the Needs reroll and Novice tags.
Comment #8
suresh prabhu parkala commentedRe-rolled patch please review.
Comment #9
drupal.ninja03 commentedPatch from #8 is working.
Looks good to me!
Comment #10
HitbyWhen I apply the patch in #8 to the dev release (on a D9.0.5 site) I get a WSOD when attempting to change the grants on a node. I get the following error -
I'd really appreciate any help with this.
Thanks,
Dan
Comment #11
waspper commentedHello guys.
I confirm bug mentioned at #10. It's because database connection is now added with dependency injection. Therefore, method "getConnection" is not needed/available. Attaching patch to fix this issue.
Comment #12
waspper commentedComment #13
andypostThere's now contrib drivers, so makes sense to keep it compatible, ref https://www.drupal.org/project/mysql56
Guess it needs to check other property of driver, also needs check with sqlite
Comment #14
andypostIt should use backward compatible approach https://git.drupalcode.org/project/drupal/-/blob/9.0.x/core/modules/upda...
Comment #15
ankithashettyUpdated the patch in #11 with the suggestions specified by #14 and made a couple of changes. Attaching an interdiff as well, will be easier to track the diffrence between the patches...
Thank you!
Comment #16
waspper commentedAfter checking a bit, and keeping in mind grants are taken once node is saved (what I saw, let us know if there is another way), I've added a small line to save node when grants form is submitted. This way, permissions per node are taken successfully (resolving issue at https://www.drupal.org/project/nodeaccess/issues/3169639). Attaching updated patch with this small change. Feel free to discuss/improve/change.
Comment #17
andypostI suggest to commit #15 as #16 is out if scope and already has own issue which needs tests coverage as node "knows" its grants
Comment #18
waspper commentedWell. Then let's keep #15. I'll provide small fix into the other issue, including one to work after applying #15.
Comment #19
waspper commentedOne more attempt: After playing with config_inspector, int's needed to do some changes to make it to pass. Feel free to improve/comment this new patch.
Comment #20
waspper commentedSorry. Attached wrong patch. Here the good one.
Comment #21
waspper commentedComment #22
andypostany reason to embed config into config?
It looks like a bug
This properties looks like boolean
role ID is string, so int is confusing
why that removed? class still here
Since PHP 7.0 is minimal version, please use https://www.php.net/manual/en/migration70.new-features.php#migration70.n... as core already doing
Comment #23
waspper commentedUpdated patch, to fix minor issue.
Comment #24
waspper commentedWell, I've addressed some items in #22:
1. Updated.
2. Updated.
3. Well. It's not the "machine name". It's storing the numeric ID. Not too clear yet purpose of this. Maybe this could be deleted, but needed more tests.
4. Previously deleted. Seems not needed, because it was only into a "services.yml". Maybe class is needed for later processing?
5. Updated.
Comment #25
jungleSome changes in #24 are out of scope to me.
Comment #26
alison#25 clears all deprecated code issues flagged by upgrade_status.
If someone has time to re-run
drupal-checkjust to be excessively confident about these fixes, that would be cool -- or even just if we could get one more "yep worked for me" -- bonus points if you can confirm that #10 isn't still happening! (or if you can confirm that it's an unrelated issue, nothing to do with the deprecation fixes)-------
Otherwise, I'm giving it another 1-2 weeks to sit here, and then I'll approve/merge/release. (So if you want it to be merged/released sooner, please help test!!)
Comment #27
jungle@alisonjo315, I checked myself with the patch in #25. #10 is out of scope here as the issue title indicated, it's related to #3061378: Table name typo? or #3185156: Permission to individual Users throws error on grants tab of nodes probably, or let's do it in another new issue.
Before:
After:
Comment #29
jungleLet's move forward.
Thanks!