Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

made self install much harder to use

added module whitelist for self install
added requirement for separate autoinstall/upgrade methods

This now means that in order for self install to be possible
you must define all three of the following manager options

enable_self_installation
manifest_dir
self_install_whitelist
  • Loading branch information...
commit ae04da697d4202795c273a93c942448a80015aac 1 parent 8ff266c
Matt Cockayne mattcockayne authored EvanDotPro committed
9 library/Zend/Module/Manager.php
@@ -2,6 +2,8 @@
2 2
3 3 namespace Zend\Module;
4 4
  5 +use Zend\Service\Amazon\Authentication\V1;
  6 +
5 7 use Traversable,
6 8 Zend\Config\Config,
7 9 Zend\Config\Writer\ArrayWriter,
@@ -126,7 +128,8 @@ public function loadModule($moduleName)
126 128 $this->addProvision($module);
127 129 $this->addDependency($module);
128 130 }
129   - if ($this->getOptions()->getEnableSelfInstallation()) {
  131 + if ($this->getOptions()->getEnableSelfInstallation() &&
  132 + in_array($this->getOptions()->getSelfInstallWhitelist(), $moduleName)) {
130 133 $this->installModule($module);
131 134 }
132 135 $this->runModuleInit($module);
@@ -155,7 +158,7 @@ public function installModule($module)
155 158 $this->loadInstallationManifest();
156 159 foreach ($module->getProvides() as $moduleName => $data) {
157 160 if (!isset($this->manifest->{$moduleName})) { // if doesnt exist in manifest
158   - if (is_callable(array($module, 'install'))) {
  161 + if (is_callable(array($module, 'autoInstall'))) {
159 162 if ($module->install()) {
160 163 $this->manifest->{$moduleName} = $data;
161 164 $this->manifest->{'_dirty'} = true;
@@ -166,7 +169,7 @@ public function installModule($module)
166 169 } elseif (isset($this->manifest->{$moduleName}) && // does exists in manifest
167 170 version_compare($this->manifest->{$moduleName}->version, $data['version']) < 0 // and manifest version is less than current version
168 171 ){
169   - if (is_callable(array($module, 'upgrade'))) {
  172 + if (is_callable(array($module, 'autoUpgrade'))) {
170 173 if ($module->upgrade($this->manifest->{$moduleName}->version)) {
171 174 $this->manifest->{$moduleName} = $data;
172 175 $this->manifest->{'_dirty'} = true;
29 library/Zend/Module/ManagerOptions.php
@@ -31,6 +31,13 @@ class ManagerOptions
31 31 * @var bool
32 32 */
33 33 protected $enableSelfInstallation = false;
  34 +
  35 + /**
  36 + * array of modules that have been whitelisted to allow self installation
  37 + *
  38 + * @var array
  39 + */
  40 + protected $selfInstallWhiteList = array();
34 41
35 42 /**
36 43 * Check if the config cache is enabled
@@ -158,6 +165,28 @@ public function setEnableSelfInstallation($bool)
158 165 *
159 166 * @return bool
160 167 */
  168 + public function getSelfInstallWhitelist()
  169 + {
  170 + return $this->selfInstallWhitelist;
  171 + }
  172 +
  173 +/**
  174 + * set if self installation is enabled
  175 + *
  176 + * @param bool $bool
  177 + * @return Manager
  178 + */
  179 + public function setSelfInstallWhitelist(array $list)
  180 + {
  181 + $this->selfInstallWhitelist = $list;
  182 + return $this;
  183 + }
  184 +
  185 + /**
  186 + * gets if self installation is enabled
  187 + *
  188 + * @return bool
  189 + */
161 190 public function getEnableSelfInstallation()
162 191 {
163 192 return $this->enableSelfInstallation;

0 comments on commit ae04da6

Please sign in to comment.
Something went wrong with that request. Please try again.