Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
file system
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Sep 2021 at 23:42 UTC
Updated:
13 Oct 2021 at 15:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexpottComment #3
alexpottHmmm... this is not going to work why this is causing a deprecation in PHP 8.1. Need to remove the change in #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves).
Comment #4
alexpottOh i recorded this in the commit message...
ba0e1aad825 - Fix \Drupal\KernelTests\Core\File\MimeTypeTest (3 months ago) <Alex Pott>:)
Comment #6
alexpottTrying a different fix on #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves) - see https://git.drupalcode.org/project/drupal/-/commit/114364910941ae69d58b1...
Comment #7
alexpottYep we can fix \Drupal\KernelTests\Core\File\MimeTypeTest instead. Which is good because we rely on \Drupal\Core\StreamWrapper\PrivateStream::basePath() returning NULL in a few places... for example in
\Drupal\Core\File\HtaccessWriter::defaultProtectedDirs:Comment #8
andypostI think it needs work because
\Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath()returns string but it's used in\Drupal\Core\StreamWrapper\PrivateStream::getDirectoryPath()so I think better fix (except mime test) isComment #9
andypostAll other places will work as expected getting empty string instead of
NULLComment #10
andypostWhile checked inheritance filed #3239831: Remove outdated todo in \Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath()
Comment #11
andypostKind of it
Comment #12
alexpott@andypost please read the previous comments and discussion. The fix in #11 was the fix on #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves) prior to discovering that the ONLY place this deprecation is triggered in core is while running the
\Drupal\KernelTests\Core\File\MimeTypeTest. And that's because it incorrectly uses the private stream wrapper without the setting. Fixing like you have in #11 prevents anyone else from receiving the deprecation and then fixing it properly. Going back to #7 which has been proven to fix the deprecation on #3220021: [meta] Ensure compatibility of Drupal 9 with PHP 8.1 (as it evolves) with the recent commits.Comment #13
andypostYes, I did read, the problem is that
\Drupal\Core\StreamWrapper\PrivateStream::getDirectoryPath()needs to be fixed as we expect NULL nowComment #14
andypostI mean
Comment #15
andypostMaybe better to split test fix and improvement of interface, I bet we'll get more warnings if we add return type there
Comment #16
alexpott@andypost let's open a follow-up. I think getDirectoryPath() should throw an exception if ::basePath() is NULL. The change here is the minimum to get around the exception without changing any return values... ::getDirectoryPath() already returns a NULL in this situation. That's what is happening in HEAD, it's not right and we can improve but it's not necessary to fix the deprecation.
Comment #17
alexpottSee \Drupal\Core\CoreServiceProvider::register() - we only register the wrapper if this setting is set...
Comment #18
andypostFiled follow-up #3239840: Throw exception in \Drupal\Core\StreamWrapper\PrivateStream::getDirectoryPath() when basepath() is null
RTBC as the patch in #12 is the same as #7
Comment #19
alexpottHmmm actually #17 points to an even better fix. It turns out that in kernel tests the private stream wrapper is being registered by \Drupal\KernelTests\Core\File\FileTestBase::register() - so that test base should properly create a private files directory so that it works as expected.
Comment #20
alexpott@andypost thanks for creating the follow-up. Just realised I hadn't asked the question as to what was registering the private stream wrapper - turns out it is \Drupal\KernelTests\Core\File\FileTestBase - so that's where we need to set the setting.
Comment #21
andypostGreat catch! It should fix 2 usages in contrib as well http://grep.xnddx.ru/search?text=%5CFileTestBase&filename= (link fixed)
Comment #22
andypostI find this ready
Comment #23
catchCommitted 7cc466d and pushed to 9.3.x. Thanks!
Comment #25
daffie commented