Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-35238 Do not check for write permissions when enabling the auto-d…

…eploy feature

It seems to be better to check for required permission later, when the
button to install the update is actually being displayed. Credit goes to
Dan Poltawski for suggesting this.
  • Loading branch information...
commit d80f80f386473f6586a51da57823174b05b8ba58 1 parent 56c0508
@mudrd8mz mudrd8mz authored
View
2  admin/settings/server.php
@@ -229,7 +229,7 @@
$temp->add(new admin_setting_configcheckbox('updateautocheck', new lang_string('updateautocheck', 'core_admin'),
new lang_string('updateautocheck_desc', 'core_admin'), 1));
if (empty($CFG->disableupdateautodeploy)) {
- $temp->add(new admin_setting_updateautodeploy('updateautodeploy', new lang_string('updateautodeploy', 'core_admin'),
+ $temp->add(new admin_setting_configcheckbox('updateautodeploy', new lang_string('updateautodeploy', 'core_admin'),
new lang_string('updateautodeploy_desc', 'core_admin'), 0));
}
$temp->add(new admin_setting_configselect('updateminmaturity', new lang_string('updateminmaturity', 'core_admin'),
View
1  lang/en/admin.php
@@ -1014,7 +1014,6 @@
$string['updateautocheck_desc'] = 'If enabled, your site will automatically check for available updates for both Moodle code and all additional plugins. If there is a new update available, a notification will be sent to site admins.';
$string['updateautodeploy'] = 'Enable updates deployment';
$string['updateautodeploy_desc'] = 'If enabled, you will be able to download and install available updates directly from Moodle administration pages. Note that your web server process has to have write access into folders with Moodle installation to make this work. That can be seen as a potential security risk.';
-$string['updateautodeploy_unablewriteplugins'] = 'Can\'t enable the feature - unable to write into plugin locations!';
$string['updateminmaturity'] = 'Required code maturity';
$string['updateminmaturity_desc'] = 'Notify about available updates only if the available code has the selected maturity level at least. Updates for plugins that do not declare their code maturity level are always reported regardless this setting.';
$string['updatenotifybuilds'] = 'Notify about new builds';
View
74 lib/adminlib.php
@@ -8052,77 +8052,3 @@ public function load_choices() {
return true;
}
}
-
-
-/**
- * Checkbox for the updateautodeploy setting
- *
- * This class implements the extra check to make sure that the web server
- * process user has write access to the $CFG->dirroot.
- *
- * @copyright 2012 David Mudrak <david@moodle.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class admin_setting_updateautodeploy extends admin_setting_configcheckbox {
-
- /**
- * Sets the value for the setting
- *
- * When the feature is just about to be enabled, proceed some extra checks
- * prior to setting the value.
- *
- * @param string $data the checkbox value
- * @return string empty string or error
- */
- public function write_setting($data) {
-
- // Are we just going to activate the feature?
- $currentlyenabled = $this->config_read('updateautodeploy');
- if ((string)$data === $this->yes and empty($currentlyenabled)) {
- if (!$this->plugin_locations_writeable()) {
- return get_string('updateautodeploy_unablewriteplugins', 'core_admin');
- }
- // TODO MDL-35239 check if the whole dirroot is writeable
- }
-
- // Let the parent class actually save the value.
- return parent::write_setting($data);
- }
-
- /**
- * Check if it is possible to write into plugin locations
- *
- * @return bool
- */
- private function plugin_locations_writeable() {
- global $CFG;
- require_once($CFG->libdir.'/pluginlib.php');
-
- // Check that the web server process is able to deploy new plugins of all types
- $plugintypes = get_plugin_types(true);
- foreach ($plugintypes as $plugintype => $plugintyperoot) {
- if (!is_writeable($plugintyperoot)) {
- debugging('Plugin type location not writeable: '.$plugintyperoot, DEBUG_ALL);
- return false;
- }
- }
-
- // Check that the web server process is able to modify contributed plugins
- $pluginman = plugin_manager::instance();
- $plugininfo = $pluginman->get_plugins();
- foreach ($plugininfo as $plugintype => $plugininstances) {
- foreach ($plugininstances as $pluginname => $plugininfo) {
- if ($plugininfo->is_standard()) {
- // No need to check for these now until MDL-35239 is implemented
- continue;
- }
- if (!is_writeable($plugininfo->rootdir)) {
- debugging('Contributed plugin directory not writeable: '.$plugininfo->rootdir);
- return false;
- }
- }
- }
-
- return true;
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.