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.
Work in progress, I have some weird notices related to stream wrappers that I couldn't figure out yet.
Difference is huge...
php core/scripts/run-tests.sh --class "Drupal\file\Tests\CopyTest,Drupal\file\Tests\DeleteTest,Drupal\file\Tests\LoadTest,Drupal\file\Tests\MoveTest,Drupal\file\Tests\SaveDataTest,Drupal\file\Tests\SaveTest,Drupal\file\Tests\SpaceUsedTest,Drupal\file\Tests\ValidateTest,Drupal\file\Tests\UsageTest,Drupal\file\Tests\ValidatorTest"
HEAD
File copying 110 passes, 0 fails, and 0 exceptions
File delete 24 passes, 0 fails, and 0 exceptions
File loading 42 passes, 0 fails, and 0 exceptions
^[xFile moving 110 passes, 0 fails, and 0 exceptions
File save data 93 passes, 0 fails, and 0 exceptions
File saving 16 passes, 0 fails, and 0 exceptions
File space used tests 12 passes, 0 fails, and 0 exceptions
File validate 12 passes, 0 fails, and 0 exceptions
File usage 34 passes, 0 fails, and 0 exceptions
File validator tests 29 passes, 0 fails, and 0 exceptions
Test run duration: 5 min 21 sec
With Patch:
File copying 122 passes, 0 fails, and 0 exceptions
File delete 30 passes, 0 fails, and 0 exceptions
File loading 60 passes, 0 fails, and 0 exceptions
File moving 125 passes, 0 fails, and 0 exceptions
File save data 108 passes, 0 fails, and 0 exceptions
File saving 19 passes, 0 fails, and 0 exceptions
File space used tests 15 passes, 0 fails, and 0 exceptions
File validate 15 passes, 0 fails, and 0 exceptions
File usage 45 passes, 0 fails, and 0 exceptions
File validator tests 39 passes, 0 fails, and 2 exceptions
Test run duration: 19 sec
Comment | File | Size | Author |
---|---|---|---|
#25 | test.file-managed.25-interdiff.txt | 2.09 KB | Berdir |
#25 | test.file-managed.25.patch | 21.05 KB | Berdir |
#24 | interdiff.txt | 1.17 KB | sun |
#24 | test.file-managed.24.patch | 20.91 KB | sun |
#21 | interdiff.txt | 1.25 KB | sun |
Comments
Comment #1
BerdirComment #2
jibranPlease convert it. +1000000000000000
More then 80 chars.
Comment #4
Berdir1: file-managed-dubt-2194085-1.patch queued for re-testing.
Comment #6
BerdirThat was a fun one to figure out. DrupalUnitTestBase::(un)registerStreamWrapper() was completely messed up, no idea how no other tests are failing.
Comment #8
BerdirYeah, now I'm officially scared...
Comment #11
Berdir8: file-managed-dubt-2194085-8.patch queued for re-testing.
Comment #12
BerdirGreen :)
Comment #13
sunCan we move this into
setUp()
, please?Whenever tests need to deal with global state constructs, they should ensure a clean environment in
setUp()
, becausetearDown()
is not necessarily reached (in case an exception is thrown).The circumstance mentioned in the @todo is a bug in itself.
file_get_stream_wrappers()
is only able to operate on arrays.The tests should use
drupal_static_reset('file_get_stream_wrappers')
instead of setting NULL.Seems like an easy fix that we can quickly grep for?
Comment #14
sunMoved reset of $wrappers into setUp(), reverted additional changes.
Somehow, this passes for me locally?
Comment #16
BerdirNope, the validator test fails and the reason is that this code is completely weird, first it's adding it to the top level and then adds all of it recursively to the ALL wrapper.
Maybe that function worked like this at one point, but it doesn't in HEAD. And fixing that then requires the other fixes, which are somehow magically hidden by this weird stuff ;)
The unset relies the same weirdness and doesn't require any checks because unset($wrapper[whatever]) works fine as long as $wrapper is defined, even if the variable is NULL.
Comment #17
sunThat code exactly resembles what
file_get_stream_wrappers()
is doing internally at the end of the function.Note that the static variable of
file_get_stream_wrappers()
contains both the registry of custom stream wrappers AND the type-filtered lists - on the same nesting level of the array.What needs to be addressed is that a custom stream wrapper is not removed from all type-filtered lists.
→ Fixed unregistration of type-specific stream wrappers in DrupalUnitTestBase.
Comment #18
sunFixed DrupalUnitTestBase does not properly resemble internals of file_get_stream_wrappers().
Comment #21
sunAlright, this patch will pass + properly documents the possible edge-case. :-)
The possibility of a straw call to
drupal_static_reset()
at any time is actually what made me introduce this "parallel" registry in theDrupalUnitTestBase
class in the first place, since the previously available information is simply gone. :)→ Fixed drupal_static_reset() causes static variable in file_get_stream_wrappers() to be reset to NULL.
Comment #22
BerdirChanges look good to me.
I'm still a bit confused by the drupal_static() behavior though.
I would assume that after a call to drupal_static_reset(), drupal_static('bla', array()) would return the passed default value and not NULL, which apparently still exists as an explicit value in there? I can see that file_get_stream_wrappers() calls it with no default value, so that would initialize it to NULL, but it also immediately .... oh I see. If file_get_stream_wrappers() is called and is empty, then it loads all stream wrappers but if system.module isn't around, then it doesn't find any and $wrappers_storage is never initialized as no value is ever set.
I think if we make sure that the default value is an empty array(), possibly even pre-initialize STREAM_WRAPPERS_ALL => array(), then we could IMHO better deal with that situation because the current would behavior would result in a constant re-initialization every time it is called and it is always an array?
Comment #23
BerdirThe result is that the comment in the patch is wrong, the problem is not that file_get_stream_wrappers() is *not* called, the problem is that it *is* called but no stream wrapper hook was found.
Comment #24
sunFixed and clarified comment in unregisterStreamWrapper().
Comment #25
BerdirWhat do you think about this?
This doesn't need that comment/check at all and it prevents us from invoking the hook possibly multiple times, even if it's just something that could happen in a DUBT test.
Comment #26
sunSure, that works, too :-)
Comment #27
alexpottCommitted 056096a and pushed to 8.x. Thanks!
Fixed on commit