This is a WTF and a bug, but not really fixable given how the code is written and the constants are defined. We might need to change how the functions are defined (or just the API).
define('STREAM_WRAPPERS_HIDDEN', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE);
So the assumption is that file_get_stream_wrappers(STREAM_WRAPPERS_HIDDEN) will return all wrappers which are READ or WRITE. But what the name "Hidden" suggests (And the docs tell us) is that it is any wrapper which is readable and writable but NOT shown in the UI. The author must have figured that because they didn't put | STREAM_WRAPPERS_VISIBLE there it was "off". So we expect to just get "temporary".
However, see the definition for "public":
define('STREAM_WRAPPERS_NORMAL', STREAM_WRAPPERS_WRITE_VISIBLE);
define('STREAM_WRAPPERS_WRITE_VISIBLE', STREAM_WRAPPERS_READ | STREAM_WRAPPERS_WRITE | STREAM_WRAPPERS_VISIBLE);
'public' => array(
'name' => t('Public files'),
'class' => 'DrupalPublicStreamWrapper',
'description' => t('Public local files served by the webserver.'),
'type' => STREAM_WRAPPERS_LOCAL_NORMAL,
),
So public actually just got READ, WRITE and VISIBLE.
Now when I call this:
file_get_stream_wrappers(STREAM_WRAPPERS_HIDDEN)
I get temporary (which I expected) and public (which I don't want).
This code:
array_diff_key(file_get_stream_wrappers(STREAM_WRAPPERS_ALL), file_get_stream_wrappers(STREAM_WRAPPERS_VISIBLE))
Works, but it's obviously non-intuitive.
Comments
Comment #0.0
JacobSingh CreditAttribution: JacobSingh commentedUpdated issue summary.
Comment #4
Mile23Stream wrappers are implemented as services now and the system has been rearchitected.
Closing as outdated because the last update was 2011 and because
file_get_stream_wrappers()
no longer exists: https://www.drupal.org/node/2393323Please open a new issue if this bug persists.