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.
protected function registerStreamWrapper($scheme, $class, $type = STREAM_WRAPPERS_LOCAL_NORMAL) {
if (isset($this->streamWrappers[$scheme])) {
$this->unregisterStreamWrapper($scheme);
}
My IDE says: "Required parameter $type missing" on the call to unregisterStreamWrapper().
Comment | File | Size | Author |
---|---|---|---|
#9 | 2279213-9.patch | 724 bytes | neclimdul |
Comments
Comment #1
sunComment #2
donquixote CreditAttribution: donquixote commentedUnbelievable, I just made the very same patch, but was too late :)
See also
#2028109: Convert hook_stream_wrappers() to tagged services.
Comment #3
neclimdulBeing as this isn't throwing any errors, is it possible this is just a dead code path that should be removed? Alternatively and probably more likely, should we provide test coverage for this code path?
Comment #4
sunIt's an extra safety net for convenience. The code path is not triggered in HEAD, because to my knowledge, there is no test that tries to replace an existing stream wrapper.
So alternatively, we could also remove that condition. Net effect is a PHP Warning/Error in tests that try to replace an existing stream wrapper without unregistering the existing first.
Comment #5
donquixote CreditAttribution: donquixote commentedIf you register a new stream wrapper with the same name, is it intended to remove the old?
Or should we rather throw an exception, assuming that replacing a stream wrapper unintentionally could cause trouble elsewhere?
Imo, let's apply a minimal fix here, and do the rest in #2028109: Convert hook_stream_wrappers() to tagged services..
(see the @todo in unregisterStreamWrapper())
Comment #6
sunAs mentioned in #4, PHP core throws warning/error if you try to register a scheme that is registered already.
Hence, manually throwing an exception is unnecessary, because your test will fail either way.
Comment #9
neclimdulWow, this got lost... Lets just go with the fix for now. I don't know what is really right and I'm guessing by the lack of motion that's sort of the consensus. This at least fixes the error in the code so it will work as originally intended.
Comment #10
sunYup, let's simply forward here please. Thanks for re-rolling!
My ultimate hope is that most of this funky code can hopefully be replaced by #2028109: Convert hook_stream_wrappers() to tagged services. — that's a very long shot from status quo, but one is allowed to have a vision, right?
Comment #15
sunComment #16
alexpottCommitted 351352e and pushed to 8.x. Thanks!