Closed (fixed)
Project:
Content Access
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
16 Jan 2022 at 15:21 UTC
Updated:
9 May 2023 at 18:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
hswong3i commentedComment #4
j-barnes commentedTested and confirmed that this fixes the deprecation error.
Comment #5
tr commentedFirst, if you want to fix the PHP 8.1 problems you should create a [meta] issue in this queue - there are going to be more than just this one problem, and this one issue should not be handling multiple problems.
Second, please comment on #3226569: Automated testing configurations. If there is no PHP 8.1 automated testing (or Drupal 9.4.x, or MySql 8, etc.) then there is no way to test patches for PHP 8.1 issues to prevent errors from being introduced into the code base, and no way to test patches like the above to demonstrate that they fix a particular PHP 8.1 issue. I manually triggered a PHP 8.1 test on your patch, and as you can see there are still problems. Because we don't have a test *before* the patch is applied, we can't verify that the patch solved anything.
Third, your patch is not correct. The configuration system is designed so that configuration variables have schema with declared datatypes. If this particular configuration variable does not contain a string then there's a problem in the variable declaration or use. It is not correct to ignore a type error by cast-ing it away.
Use of casts, empty(), isset(), and the like are all indications of an underlying problem that needs to be solved. Ignoring that by making the use of the variable conditional, or by coercing the type when the variable is used, isn't solving the problem - it is just putting the burden on all the code that uses this variable instead of correcting the variable definition. So specifically, this is a string type configuration variable and should never have a non-string value of NULL if it is defined and initialized and used correctly.
Comment #6
jsidigital commentedThis worked for me.
Attached is the patch version.
Comment #7
bohus ulrychHi, strange - I was not able to apply this patch. Patching ActionCommonTrait.php was rejected.
At the end I realized that it is build for 8.x-1.0-alpha3.
But for the latest dev one 8.x-1.x-dev (updated 23 Jan 2022) it needs to be adjusted because there was update of ActionCommonTrait.php
https://git.drupalcode.org/project/content_access/-/blob/8.x-1.0-alpha3/...
https://git.drupalcode.org/project/content_access/-/blob/8.x-1.x/src/Plu...
Here is my slightly updated version which works with latest dev.
Comment #8
bohus ulrychSorry, there was one more change in that file.
New patch attached.
Comment #9
spudley commentedI can confirm that I'm getting this error on the current dev release when running PHP 8.1. The patch seems good, so hopefully it can be merged in.
Comment #10
lapurddrupal commentedWorks fine!!!. Thanks a lot. D. 9.3.15 , PHP 8.1.3 , 10.5.15-MariaDB-
Comment #11
gisleAutomated test still says "Patch Failed to Apply".
Comment #12
flyke commentedPatch #8 also works on D9.4.1, PHP 8.1.6, content_access 1.x-dev@dev
Comment #13
gisleI believe you when you say it works. But we need to figure out why it does not pass the automated tests and reroll to make it pass (or rewrite the test if the test is buggy). This module is horribly complex, and automated tests are necessary to prevent regressions from happening.
I still don't have a test server running PHP 8.1. Until I get around to setting one up, I cannot work on this myself.
Comment #14
bserem commentedPatch was against a drupal installation and not against the module. Fixed and attached.
Comment #15
superlolo95 commented#Seems to fix the error message
Comment #16
bserem commentedI'm having a hard time debugging the tests, if anyone wants to have a look. It should be the only thing remaining here.
Comment #17
bserem commentedSo, I've spend a lot of time on this one. The failing tests are in combination with ACL. I can't tell if it is "ACL" that needs to be fixed or "content_access".
Thing is that this can drive people mad, in the end it lands on core and it needs some effort to hunt it down.
Comment #18
gislebserem (and the others who have participated in solving this),
thank you so much for your time and effort!
I really want to have a stable release of this, with tests.
Looking back, I believe this project has suffered galloping featuratis. It simply tries to do too much, for too many different use cases. Status today is that there is a lot of technological debt and too little resources to pay it. The project's code base has become very hard and resource intensive to maintain. It is time to take a step back.
AFAIK, the ACL integration never worked right – not even in the Drupal 7 version.
I've already decided to pull the integration with Rules (see #3306154: Restore Content Access Rules Integrations), and the I think we need to pull integration with ACL as well. See #3306205: Remove ACL integration.
I hope that doing so will simplify things, so that the tests will allow your fix for PHP 8.1 to be committed.
Comment #19
bserem commentedhey @gisle, thanks for your reply. I'm all in favor of removing some fat. That said, I do not need/use ACL in my case, so I can't speak for anyone.
Comment #20
gisleIf you need ACL, you obviously need to get this fixed, one way or another. AFAIK, nobody else is working on fixing this.
In that case, you may want to check out Flexi Access
It was initially a fork of the ACL integration in this project, because we couldn't get ACL to work with Content Access. I still use it on a few Drupal 7 production sites.
Note: It has not been upgraded to Drupal 9/10, but I suspect that an upgrade shall be less work than getting the ACL integration of Content Access working.
If you want to have a go at it, just let me know, and I'll add you as co-maintainer to Flexi Access. Or, if you want to work on fixing the ACL integration in Content Access instead, I can add you as co-maintainer here (and close the issue about ripping out the ACL integration)
Comment #21
xem8vfdh commented@bserem, thanks for the help! If you've got time to co-maintain, that would be amazing, though I know it's a tough ask.
Comment #22
tr commentedWhy are the configuration settings being serialized and unserialzed in the first place? That seems to be legacy from D7 when things were stored in untyped system variables. Now that we have configuration settings and configuration schema, there is no need to serialize anything in configuration. And as I said above, if you define your settings and your settings schema properly then casts should never be needed.
I think the patch as it stands is just digging a deeper hole - it's not fixing anything, it's just hiding the problem.
Comment #23
bserem commented@xeM8VfDh thanks for the offer, really appreciate it! I have a very small experience with content_access, from projects I inherited, and I do not feel I can take it further, not now anyway. If at any point I feel comfy about such a task I will not hesitate to ask, but right now is not the right moment for me.
Comment #24
gisleUploading patch to run tests.
Comment #25
rajab natshahThank you.
Patch #14 is working
Comment #26
bserem commentedPatch #24 does not contain lots of code from patch #14.
With #14 things are smooth in my sites, with #24 I get a lot of WSOD pages.
Maybe a re-roll based on #14 is a good idea?
Comment #27
bserem commentedComment #28
jaime@gingerrobot.com commentedI tried the following:
* Rerolling patch #24
To only use arrays the schema of the content access data will have to change to an array from a string.
web/modules/contrib/content_access/config/schema/content_access.schema.yml
* Rerolling patch #14
The issue here is the data is saved as a string, but it will not then transform back to an array.
* I tried using $serializer = \Drupal::service('serializer'); instead of the PHP ones but that was no good.
* Then I just saved content access data again.
It changed from a format like:
a:3:{s:8:"view_own";a:2:{i:0;s:12:"site_manager";i:1;s:13:"administrator";}s:4:"view";a:1:{i:0;s:13:"administrator";}s:8:"per_node";i:1;}To a format like:
Comment #29
oleh chemerys commented@bserem Hi, I have made investigation further and found an issue why the tests are failing. In fact it's not even related to unserialize issue, but the problem is in ACL module itself. See related issue and patch I added there. After applying the patch from related issue #14 patch no longer fails testing for me.
Comment #30
oleh chemerys commentedHi @jaimekristene
You mentioned there are some potential issues while using patch #14. Could you please specify the cases? I've been doing some testing with that and was not able to identify anything going wrong.
Comment #31
jaime@gingerrobot.com commented#30 @oleg-chemerys
You're right, The patch in #14 works for me.
TODO:
* Remove the ACL requirement so the tests pass - https://www.drupal.org/project/content_access/issues/3306205
* Create a separate ticket to ask to swap content_access schema to store as an array instead of a string for the content_access_node_type.
Comment #32
anybodyComment #33
gisleThis has to be postponed until at least one of these is fixed:
The first one is for this module and will be committed as soon as a usable patch or merge request exists. The second one depends on the maintainers of ACL commits the existing RTBC patch.
Comment #34
pallas athena commentedThank you. Patch #14 worked for me.
Comment #35
igonzalez commentedThank you. Patch #14 worked for me.
Comment #37
afagioliThank you.
Patch #14 is working
Comment #38
deg commentedThanks, Patch #14 worked for me.
Comment #39
arturopanettaI tested patch #14 on Drupal 9.5 and PHP 8.1 and it works.
Comment #40
anybodyNothing seems to happen at ACL anymore. Should this really be postponed on that? PHP8.1 is the recommended PHP version and this is filling up logs.
Comment #41
xem8vfdh commentedI agree with #40
Comment #42
gisleWhat do you suggest? It is Postponed until ACL is fixed. Is there anything to do but wait until that happens.
Comment #43
lpsolit commented@gisle: did you notice my patch about ACL (see issue 3306205)? I got no comment about it.
Comment #44
gisleYes. I see that #3306205: Remove ACL integration is suggested as an "untested patch", but with no community reviews. It is not on my schedule to review it.
This module is currently working OK for my use cases. I understand that there are some use cases were it is not working, I can't allocate resources to test those out without someone paying me to do so.
Comment #45
anybody@gisle: As I understand #31 the
(string)casting in #14 fixes the message and other things can be solved in follow-ups?That was my point in #40. Perhaps I should have been more clear or I'm missing something here?
Comment #46
lapurddrupal commentedPatch #14 on Drupal 9.5.4 and PHP 8.12 worked for me. Thanks to you!!!
Comment #47
brunodboThis might be related to this core issue: #3300404: Handle nullable serialized field columns
Comment #48
taran2lSo, patch from #14 works as expected and does fix the issue, but it has an extra safe code that is not needed.
Approach from #24 is a valid try to improve the module by storing config not as serialized string, but like a normal array, but this approach requires a) update to config schema b) hook_update to resave all settings => clearly not the scope of this issue.
Also, postponing this on ACL fixes can be worked around. See the attached patch
Comment #49
taran2lComment #50
taran2lOkay, enabling deprecations is not part of the scope either, let's try this minimalistic patch
Comment #51
taran2lHuh ..
Comment #52
taran2lComment #53
taran2lACL has been updated, hence the new simple patch
Comment #54
taran2lComment #55
xem8vfdh commentedthanks @Taran2L. I can test this later. In any case, should we hold off until the new ACL release it published, and use a new version of your latest patch that doesn't depend on the dev branch of ACL? Or do you think this is ready to go as is?
@gisle, thought?
Comment #56
xem8vfdh commentedhey @Taran2L and @hswong3i, I am unable to reproduce this error.
On my dev instance, I have the following in
settings.local.php:I am running PHP 8.1, and I have followed the steps in the OP: Navigate to Manage » Structure » Content types. Under operations, Select "Access control" for any content type.
I am not seeing this warning in any of my php/nginx log files. Any advice?
Comment #58
gisleThe fix in patch in comment #54 has been pushed to the latest development snapshot.
Hopefully, the fix (#3324285: [PHP 8.1] Deprecated function: mb_strlen(): Passing null to parameter #1) in ACL get committed to a tagged release so that we can go back to using the stable version of ACL again.
Comment #59
xem8vfdh commentedthanks @gisle and @Taran2L!
I am working on the ACL issue(s). Savlis popped in to do some work, but seems to have gone absent again. I'm hopefully he will return to clean up a few more loose ends and publish a new release. 🤞