aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-27 02:37:16 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-04-27 02:37:16 +0000
commit82593cd2bc056da73caa1b1e981c5a9ead0f1bf2 (patch)
treefe416e8ac58891f9689c8a08170069921c0d8805 /engine
parent56ba85a9571c854c6054ad70b88dc15660a053fa (diff)
downloadelgg-82593cd2bc056da73caa1b1e981c5a9ead0f1bf2.tar.gz
elgg-82593cd2bc056da73caa1b1e981c5a9ead0f1bf2.tar.bz2
Refs #3362. Plugins don't check deps upon boot. Made package and manifest private properties of ElggPlugin and added ->getPackage() and ->getManifest().
git-svn-id: http://code.elgg.org/elgg/trunk@9030 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggPlugin.php74
-rw-r--r--engine/classes/ElggPluginPackage.php4
-rw-r--r--engine/lib/admin.php4
-rw-r--r--engine/lib/deprecated-1.8.php2
-rw-r--r--engine/lib/plugins.php39
5 files changed, 63 insertions, 60 deletions
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php
index 20a8673de..eb911455a 100644
--- a/engine/classes/ElggPlugin.php
+++ b/engine/classes/ElggPlugin.php
@@ -9,8 +9,8 @@
* @subpackage Plugins.Settings
*/
class ElggPlugin extends ElggObject {
- public $package;
- public $manifest;
+ private $package;
+ private $manifest;
private $path;
private $pluginID;
@@ -76,18 +76,6 @@ class ElggPlugin extends ElggObject {
// load the rest of the plugin
parent::__construct($existing_guid);
}
-
- // We have to let the entity load so we can manipulate it with the API.
- // If the path is wrong or would cause an exception, catch it,
- // disable the plugin, and emit an error.
- try {
- $this->package = new ElggPluginPackage($this->path, false);
- $this->manifest = $this->package->getManifest();
- } catch (Exception $e) {
- // we always have to allow the entity to load.
- elgg_log("Failed to load $this->guid as a plugin. " . $e->getMessage(), 'WARNING');
- $this->errorMsg = $e->getmessage();
- }
}
/**
@@ -152,7 +140,7 @@ class ElggPlugin extends ElggObject {
* @return array
*/
public function getAvailableTextFiles() {
- $filenames = $this->package->getTextFilenames();
+ $filenames = $this->getPackage()->getTextFilenames();
$files = array();
foreach ($filenames as $filename) {
@@ -562,13 +550,13 @@ class ElggPlugin extends ElggObject {
return false;
}
- if (!$this->package instanceof ElggPluginPackage) {
+ if (!$this->getPackage() instanceof ElggPluginPackage) {
$this->errorMsg = elgg_echo('ElggPlugin:NoPluginPackagePackage', array($this->getID(), $this->guid));
return false;
}
- if (!$this->package->isValid()) {
- $this->errorMsg = $this->package->getError();
+ if (!$this->getPackage()->isValid()) {
+ $this->errorMsg = $this->getPackage()->getError();
return false;
}
@@ -607,8 +595,8 @@ class ElggPlugin extends ElggObject {
* @return bool
*/
public function canActivate($site_guid = null) {
- if ($this->package) {
- return $this->package->isValid() && $this->package->checkDependencies();
+ if ($this->getPackage()) {
+ return $this->getPackage()->isValid() && $this->getPackage()->checkDependencies();
}
return false;
@@ -708,9 +696,9 @@ class ElggPlugin extends ElggObject {
* @throws PluginException
*/
public function start($flags) {
- if (!$this->canActivate()) {
- return false;
- }
+// if (!$this->canActivate()) {
+// return false;
+// }
// include start file
if ($flags & ELGG_PLUGIN_INCLUDE_START) {
@@ -958,4 +946,44 @@ class ElggPlugin extends ElggObject {
public function getError() {
return $this->errorMsg;
}
+
+ /**
+ * Returns this plugin's ElggPluginManifest object
+ *
+ * @return ElggPluginManifest
+ */
+ public function getManifest() {
+ if ($this->manifest instanceof ElggPluginManifest) {
+ return $this->manifest;
+ }
+
+ try {
+ $this->manifest = $this->getPackage()->getManifest();
+ } catch (Exception $e) {
+ elgg_log("Failed to load manifest for plugin $this->guid. " . $e->getMessage(), 'WARNING');
+ $this->errorMsg = $e->getmessage();
+ }
+
+ return $this->manifest;
+ }
+
+ /**
+ * Returns this plugin's ElggPluginPackage object
+ *
+ * @return ElggPluginPackage
+ */
+ public function getPackage() {
+ if ($this->package instanceof ElggPluginPackage) {
+ return $this->package;
+ }
+
+ try {
+ $this->package = new ElggPluginPackage($this->path, false);
+ } catch (Exception $e) {
+ elgg_log("Failed to load package for $this->guid. " . $e->getMessage(), 'WARNING');
+ $this->errorMsg = $e->getmessage();
+ }
+
+ return $this->package;
+ }
}
diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php
index 4daab381e..bad99362f 100644
--- a/engine/classes/ElggPluginPackage.php
+++ b/engine/classes/ElggPluginPackage.php
@@ -334,13 +334,13 @@ class ElggPluginPackage {
// first, check if any active plugin conflicts with us.
foreach ($enabled_plugins as $plugin) {
- $temp_conflicts = $plugin->manifest->getConflicts();
+ $temp_conflicts = $plugin->getManifest()->getConflicts();
foreach ($temp_conflicts as $conflict) {
if ($conflict['type'] == 'plugin' && $conflict['name'] == $this_id) {
$result = $this->checkDepPlugin($conflict, $enabled_plugins, false);
// rewrite the conflict to show the originating plugin
- $conflict['name'] = $plugin->manifest->getName();
+ $conflict['name'] = $plugin->getManifest()->getName();
if (!$full_report && !$result['status']) {
return $result['status'];
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 06418c44f..61f64c8b3 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -329,7 +329,7 @@ function elgg_admin_add_plugin_settings_menu() {
elgg_register_menu_item('page', array(
'name' => $plugin_id,
'href' => "admin/plugin_settings/$plugin_id",
- 'text' => $plugin->manifest->getName(),
+ 'text' => $plugin->getManifest()->getName(),
'parent_name' => 'settings',
'context' => 'admin',
'section' => 'configure',
@@ -541,7 +541,7 @@ function admin_markdown_page_handler($pages) {
return true;
}
- $title = $plugin->manifest->getName() . ": $filename";
+ $title = $plugin->getManifest()->getName() . ": $filename";
$text = Markdown($file_contents);
$body = elgg_view_layout('admin', array(
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index bb52881cd..595b12aea 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -1667,7 +1667,7 @@ function get_installed_plugins($status = 'all') {
if ($include) {
$installed_plugins[$plugin->getID()] = array(
'active' => $plugin->isActive(),
- 'manifest' => $plugin->manifest->getManifest()
+ 'manifest' => $plugin->getManifest()->getManifest()
);
}
}
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index 0947b7a8e..5aed3065a 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -266,9 +266,9 @@ function elgg_is_active_plugin($plugin_id, $site_guid = null) {
/**
* Loads all active plugins in the order specified in the tool admin panel.
*
- * @note This is called on every page load and includes additional checking that plugins
- * are fit to be loaded. If a plugin is active and problematic, it will be disabled
- * and a visible error emitted.
+ * @note This is called on every page load. If a plugin is active and problematic, it
+ * will be disabled and a visible error emitted. This does not check the deps system because
+ * that was too slow.
*
* @return bool
*/
@@ -307,17 +307,6 @@ function elgg_load_plugins() {
$plugins = elgg_get_plugins('active');
if ($plugins) {
foreach ($plugins as $plugin) {
- // check if plugin can be started and try to start it.
- // if anything is bad, disable it and emit a message.
- if (!$plugin->isValid()) {
- $plugin->deactivate();
- $msg = elgg_echo('PluginException:MisconfiguredPlugin', array($plugin->getID(), $plugin->guid));
- register_error($msg);
- $return = false;
-
- continue;
- }
-
try {
$plugin->start($start_flags);
} catch (Exception $e) {
@@ -345,11 +334,10 @@ function elgg_load_plugins() {
* Returns an ordered list of plugins
*
* @param string $status The status of the plugins. active, inactive, or all.
- * @param bool $include_bad Include physically deleted and invalid plugins?
* @param mixed $site_guid Optional site guid
* @return array
*/
-function elgg_get_plugins($status = 'active', $include_bad = false, $site_guid = NULL) {
+function elgg_get_plugins($status = 'active', $site_guid = null) {
$db_prefix = get_config('dbprefix');
$priority = elgg_namespace_plugin_private_setting('internal', 'priority');
@@ -388,22 +376,9 @@ function elgg_get_plugins($status = 'active', $include_bad = false, $site_guid =
break;
}
- if ($include_bad) {
- $old_ia = elgg_set_ignore_access(true);
- }
-
+ $old_ia = elgg_set_ignore_access(true);
$plugins = elgg_get_entities_from_relationship($options);
-
- if ($include_bad) {
- elgg_set_ignore_access($old_ia);
- } else {
- // remove bad plugins
- foreach ($plugins as $i => $plugin) {
- if (!$plugin->isValid()) {
- unset ($plugins[$i]);
- }
- }
- }
+ elgg_set_ignore_access($old_ia);
return $plugins;
}
@@ -573,7 +548,7 @@ function elgg_get_plugins_provides($type = null, $name = null) {
$provides = array();
foreach ($active_plugins as $plugin) {
- if ($plugin_provides = $plugin->manifest->getProvides()) {
+ if ($plugin_provides = $plugin->getManifest()->getProvides()) {
foreach ($plugin_provides as $provided) {
$provides[$provided['type']][$provided['name']] = array(
'version' => $provided['version'],