Problem/Motivation
I got "Fatal error: Class name must be a valid object or a string in /core/modules/image/src/Entity/ImageStyle.php on line 174" when "$this->getStreamWrapperManager()->getClass($source_scheme)" return null value on line number 173 in ImageStyle.php.
When a streamWrapper isn't (yet) registered, the call to $this->getStreamWrapperManager()->getClass($source_scheme); can return FALSE, the logic should account for that possibility.
Proposed resolution
FALSE is a valid return option for \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface::getClass, the code should account for it
Remaining tasks
Find a way to reproduce the bug or at least describe what exactly needed to happen to get this failure.
Write a test
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
None.
Comments
Comment #2
b n pandey commentedI fixed this issue by applying this patch. Providing patch here.
Comment #3
swentel commentedhow can we reproduce this ?
Comment #5
rondog469 commentedI am getting this error too, but I'd like to know why $class is null. StreamWrapperInterface seems to be the problem.
Comment #8
simeI can't really explain the situation, but for google foo, I got this issue with the youtube stream wrapper, when I synced a prod database locally and I guess the thumbnails didn't exist yet.
Comment #9
borisson_Without a way to reproduce this issue, we can't write a test. And that test is needed to make sure that this bug doesn't reappear.
Comment #10
nashkrammer commentedI uninstalled s3fs module after which I updated core from 8.3.9 to 8.5.3. Then when I reinstalled s3fs module using composer it gave me this error.
There is related issue in the s3sf module version 8.x-2.0-alpha0
Comment #11
niklp commentedI hit this problem when deploying a site. Turns out I had disabled the private file setting in settings.php while trying to get an SELinux issue fixed. Making sure my private file setting was valid again fixed this for me. Would have been nice to get a relevant error, but when does that ever happen these days...
Comment #13
annetee commentedI'm having the same issue and am not using the s3fs module. I've attached a slightly updated patch that fixes an error where `$is_writeable` isn't defined.
Comment #14
annetee commentedComment #15
betoissues commentedWas having the same issue. Applying the patch in #13 worked for me.
Comment #16
tepelena commentedSame problem.
Comment #17
satrece commentedI was having same issue once i upgrade from 8.6.15 to 8.7.x. Patch #13 worked for me.
Comment #18
rollingnet commentedSame issue without having installed any of the module described above.
Patch #13 solved the issue for me too.
It's a blocking issue, since when it appears, the Drupal installation becomes almost unusable.
Time to test deeply this patch and include it in the next Drupal release?
Comment #19
tatarbjI've updated the IS and rerolled the patch on 8.7.x.
Comment #21
elly commentedRan into the same problem after upgrading to 8.7.1. Only happened when running cron for me. Patch in #19 worked.
Comment #22
borisson_I don't think the test-fail is related to this. In any case we would need a test.
Comment #23
sam-elayyoub commentedThe reason for this problem is missing configurations or files within the private folder.
I'm using D8.5.6 and here's how I fixed mine when I got this problem. It's not the right solution but this patch can let you ignore the class in case of missing info for your files.
Comment #24
sam-elayyoub commentedComment #25
sam-elayyoub commentedComment #26
tatarbjthe issue is definitely not fixed, also patch on 8.7.x does not apply.
Comment #27
sam-elayyoub commentedthe patch should work on. 8.7 but the problem in 8.7 the file been modified but the function stayed the same which made the patch needs some new modifications or do the change manually within another patch but 8.5 and 8.6 would never match in one patch with 8.7 because of the other changes within the file and the line number is different
just the changes 8.7 needed:
- replace the line below
$class = $this->getStreamWrapperManager()->getClass($source_scheme);
with the lines below:
if ($class) {
$is_writable = $class::getType() & StreamWrapperInterface::WRITE;
} else {
$is_writable = null;
}
Comment #28
developmenticon commentedUpdated Patch for Drupal 8.7
Comment #29
sam-elayyoub commentedComment #30
tatarbj@sam-elayyoub, please do NOT change the status of the issue to fixed when it's not. It needs test coverage according to #22 and also fixed means it's committed, that is not true.
Back to needs work to continue implementing tests.
Comment #31
sam-elayyoub commented@tatarbj Keeping this as needs work is a little tricky when a final patch tested on different versions and validated, then the meaning of needs work is not correct, I agree closed means committed and applied but if we keep the ticket open needs work, then it's a wasting of time for dev teams who thinks they can still apply patches and waste their time on a fixed tested ticket.
I will leave it open but to be honest, it's a core module patch and this should be fixed before releasing a new version before committing what's fixed for now.
Regards
Sam
Comment #32
borisson_Well, needs work means that the patch is not yet complete. Because this still needs tests before it can be committed the patch is not yet complete, so needs work is the correct state.
It does not waste time. It needs tests.
It is not yet committed to 8.8.x yet either, so if you'd want to use this patch, it would still need to applied manually (or with composer-patches).
It needs tests, then it can get committed to 8.8.x (and possibly backported to 8.7.x).
In summary, this needs tests and a clear way to reproduce this. Right now this patch only fixes the effect and not the root cause of this issue.
Comment #33
anantjain60 commentedHello community, I'm also facing this issue
Comment #34
idebr commentedAttached patch adds test coverage (interdiff-28-34 =2849413-34-test-only.patch).
Comment #36
lendudeThe kernel test is indicative of the problem, since KernelTests use the vfs StreamWrapper and that isn't registered anywhere, the test fails. This is probably the same problem others are facing: a StreamWrapper that isn't registered (yet).
Since FALSE is a valid return option for
\Drupal\Core\StreamWrapper\StreamWrapperManagerInterface::getClass, the code should account for it, and with this fix, it does.Updated the IS to add the reasoning
Comment #37
larowlanThanks for your work here folks, this is indeed a difficult issue to reproduce, because stream wrappers are registered in pre-bootstrap code in the kernel, so the only way you're getting into this scenario is if you have references to disabled stream wrappers in your database.
The test is a reasonable workaround that demonstrates the problem, and as @Lendude points out, FALSE is a valid return.
Adding issue credits
Comment #39
larowlanCommitted 3237440 and pushed to 8.8.x. Thanks!
c/p to 8.7.x