Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
It is unclear to me why \Drupal\automatic_updates\ReadinessChecker\Filesystem::exists()
itself exists 😜
It is just wrapper around file_exists()
From what I can tell from #3043521-48: [META] Update readiness checks for autoupdate (pre-flight check) it was added when the patch stopped using league/flysystem
file_exists()
is called elsewhere in the module without a wrapper. Core also calls this many places directly.
Proposed resolution
Remove the method and just call file_exists()
directly
if should remain the doc should be updated to explain why it is needed.
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff_14-15.txt | 2.27 KB | heddn |
#15 | 3157850-15.patch | 13.61 KB | heddn |
Comments
Comment #2
tedbowComment #4
S_Bhandari CreditAttribution: S_Bhandari at Srijan | A Material+ Company for Drupal India Association commentedComment #5
S_Bhandari CreditAttribution: S_Bhandari at Srijan | A Material+ Company for Drupal India Association commentedAdded a patch for the same.
Comment #6
S_Bhandari CreditAttribution: S_Bhandari at Srijan | A Material+ Company for Drupal India Association commentedComment #7
tedbow@S_Bhandari patch #5 is exactly the same as #2 correct? I am not sure why you uploaded it.
The current tests need to fixed to no rely on
exists()
method. It is protected method anyways so the tests shouldn't rely on it.Comment #8
tedbowI think this good idea still remove but I makes the current tests break. The test mocks the class we are trying to test changes the return values of the protected methods. So I don't think it is actually testing the methods which I think should be down my just calling the public methods of the class with mocked argument objects if needed. Right now we are testing the internal logic of the class not the public interface.
It is tricky with this class because we need files to check but I think we can use
org\bovigo\vfs\vfsStream
as the core test\Drupal\Tests\Core\Extension\InfoParserUnitTest
does.Here is a start I have left the current test in place and started a new one for now. I can work more on this later
Comment #9
S_Bhandari CreditAttribution: S_Bhandari at Srijan | A Material+ Company for Drupal India Association commentedHi @tedbow,
Sorry for that, mistakenly I overlooked the complete patch and just worked on it when I saw the test results failed. Yes, you are right about the logic of why the tests are getting failed. Thanks for explaining it better.
Thanks.
Comment #10
tedbowComment #12
tedbowOk finished the test. I could figure out a way make the test use the real
\Drupal\automatic_updates\ReadinessChecker\Filesystem::areSameLogicalDisk()
becausestat()
does work with vfsStream.Comment #14
tedbowfixed the test
Comment #15
heddnChecking if a few phpcs issues are now resolved.
Comment #18
heddnFixed on commit: