]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixed bug when trying to set a plugin's priority to 1 without using "first."
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 6 Feb 2011 20:02:50 +0000 (20:02 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 6 Feb 2011 20:02:50 +0000 (20:02 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8048 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggPlugin.php

index 731875755fa11da6fa6ade815a9928a3d4c6f83c..c682319e317f340d0ff1c6c71502a0b65a842a86 100644 (file)
@@ -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