From d35c99c3a9c7397b448b29db7407501b4824357e Mon Sep 17 00:00:00 2001 From: brettp Date: Sun, 6 Feb 2011 20:02:50 +0000 Subject: Fixed bug when trying to set a plugin's priority to 1 without using "first." git-svn-id: http://code.elgg.org/elgg/trunk@8048 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggPlugin.php | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'engine/classes/ElggPlugin.php') diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index 731875755..c682319e3 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -181,25 +181,16 @@ class ElggPlugin extends ElggObject { $old_priority = (int) $this->getPriority(); $max_priority = elgg_get_max_plugin_priority(); - // (int) 0 matches (string) first, so cast to string. - $priority = (string) $priority; - - switch ($priority) { - case '+1': - $priority = $old_priority + 1; - break; - - case '-1': - $priority = $old_priority - 1; - break; - - case 'first': - $priority = 1; - break; - - case 'last': - $priority = $max_priority; - break; + // can't use switch here because it's not strict and + // php evaluates +1 == 1 + if ($priority === '+1') { + $priority = $old_priority + 1; + } elseif ($priority === '-1') { + $priority = $old_priority - 1; + } elseif ($priority === 'first') { + $priority = 1; + } elseif ($priority === 'last') { + $priority = $max_priority; } // should be a number by now -- cgit v1.2.3