Commit 14189a74 authored by catch's avatar catch
Browse files

Issue #2353357 by Berdir: hook_stream_wrappers_alter() is broken since modules...

Issue #2353357 by Berdir: hook_stream_wrappers_alter() is broken since modules are not loaded on demand, also change to an event since it's the last hook that forces this during bootstrap
parent c02f12b7
......@@ -886,7 +886,6 @@ services:
parent: default_plugin_manager
stream_wrapper_manager:
class: Drupal\Core\StreamWrapper\StreamWrapperManager
arguments: ['@module_handler']
calls:
- [setContainer, ['@service_container']]
stream_wrapper.public:
......
......@@ -103,8 +103,6 @@
* 'type' bitmask has an on bit for each bit specified in $filter are
* returned.
*
* @see hook_stream_wrappers_alter()
*
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal::service('stream_wrapper_manager')->getWrappers().
*/
......
......@@ -14,8 +14,6 @@
* Provides a StreamWrapper manager.
*
* @see file_get_stream_wrappers()
* @see hook_stream_wrappers_alter()
* @see system_stream_wrappers()
* @see \Drupal\Core\StreamWrapper\StreamWrapperInterface
*/
class StreamWrapperManager extends ContainerAware {
......@@ -49,23 +47,6 @@ class StreamWrapperManager extends ContainerAware {
*/
protected $wrappers = array();
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs a StreamWrapperManager object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
/**
* Provides Drupal stream wrapper registry.
*
......@@ -279,8 +260,6 @@ public function addStreamWrapper($service_id, $class, $scheme) {
* Internal use only.
*/
public function register() {
$this->moduleHandler->alter('stream_wrappers', $this->info);
foreach ($this->info as $scheme => $info) {
$this->registerWrapper($scheme, $info['class'], $info['type']);
}
......
......@@ -10,17 +10,6 @@
* @{
*/
/**
* Alters the list of PHP stream wrapper implementations.
*
* @see file_get_stream_wrappers()
* @see \Drupal\Core\StreamWrapper\StreamWrapperManager
*/
function hook_stream_wrappers_alter(&$wrappers) {
// Change the name of private files to reflect the performance.
$wrappers['private']['name'] = t('Slow files');
}
/**
* Control access to private file downloads and specify HTTP headers.
*
......
......@@ -87,7 +87,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'item',
'#title' => t('Private file system path'),
'#markup' => (PrivateStream::basePath() ? PrivateStream::basePath() : t('Not set')),
'#description' => t('An existing local file system path for storing private files. It should be writable by Drupal and not accessible over the web. This must be changed in settings.php. See the online handbook for <a href="@handbook">more information about securing private files</a>.', array('@handbook' => 'http://drupal.org/documentation/modules/file')),
'#description' => t('An existing local file system path for storing private files. It should be writable by Drupal and not accessible over the web. This must be changed in settings.php'),
);
$form['file_temporary_path'] = array(
......
......@@ -37,15 +37,28 @@ function testFileConfigurationPage() {
'file_default_scheme' => 'private',
);
// Check that all fields are present.
foreach ($fields as $field => $path) {
$this->assertFieldByName($field);
}
// Check that public and private can be selected as default scheme.
$this->assertText('Public local files served by the webserver.');
$this->assertText('Private local files served by Drupal.');
$this->drupalPostForm(NULL, $fields, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
foreach ($fields as $field => $value) {
$this->assertFieldByName($field, $value);
}
// Remove the private path, rebuild the container and verify that private
// can no longer be selected in the UI.
$settings['settings']['file_private_path'] = (object) array(
'value' => '',
'required' => TRUE,
);
$this->writeSettings($settings);
$this->rebuildContainer();
$this->drupalGet('admin/config/media/file-system');
$this->assertText('Public local files served by the webserver.');
$this->assertNoText('Private local files served by Drupal.');
}
}
......@@ -437,6 +437,9 @@
* must be absolute, outside of the the Drupal installation directory and not
* accessible over the web.
*
* Note: Caches need to be cleared when this value is changed to make the
* private:// stream wrapper available to the system.
*
* See http://drupal.org/documentation/modules/file for more information about
* securing private files.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment