Fixed bug #17282: Workspaces module get placed on "top" of all Web> modules if sysext...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_extmgm.php
index 75e8f66..d91b24b 100644 (file)
@@ -705,17 +705,24 @@ final class t3lib_extMgm {
                                        case 'after':
                                        case 'before':
                                                $pointer = 0;
                                        case 'after':
                                        case 'before':
                                                $pointer = 0;
+                                               $found = FALSE;
                                                foreach ($mods as $k => $m) {
                                                        if (!strcmp($m, $modRef)) {
                                                                $pointer = strtolower($place) == 'after' ? $k + 1 : $k;
                                                foreach ($mods as $k => $m) {
                                                        if (!strcmp($m, $modRef)) {
                                                                $pointer = strtolower($place) == 'after' ? $k + 1 : $k;
+                                                               $found = TRUE;
                                                        }
                                                }
                                                        }
                                                }
-                                               array_splice(
-                                                       $mods, // The modules array
-                                                       $pointer, // To insert one position from the end of the list
-                                                       0, // Don't remove any items, just insert
-                                                       $sub // Module to insert
-                                               );
+                                               if ($found) {
+                                                       array_splice(
+                                                               $mods, // The modules array
+                                                               $pointer, // To insert one position from the end of the list
+                                                               0, // Don't remove any items, just insert
+                                                               $sub // Module to insert
+                                                       );
+                                               } else {
+                                                               // If requested module is not found: Add at the end
+                                                       array_push($mods, $sub);
+                                               }
                                        break;
                                        default:
                                                if (strtolower($place) == 'top') {
                                        break;
                                        default:
                                                if (strtolower($place) == 'top') {