@@ -86,12 +86,15 @@ public function handle(): int
8686 return 1 ;
8787 }
8888
89- $ this ->info ("Module \"{$ newModule ->name }\" ( {$ newModule ->version }) successfully installed! " );
89+ $ this ->info ("Module \"{$ newModule ->name }\" ( {$ newModule ->getVersion () }) successfully installed! " );
9090 $ this ->info ("Install location: {$ moduleFolder }/ {$ newModule ->folderName }" );
9191 $ this ->cleanup ();
9292 return 0 ;
9393 }
9494
95+ /**
96+ * @param ThemeModule[] $existingModules
97+ */
9598 protected function handleExistingModulesWithSameName (array $ existingModules , ThemeModuleManager $ manager ): bool
9699 {
97100 if (count ($ existingModules ) === 0 ) {
@@ -100,7 +103,7 @@ protected function handleExistingModulesWithSameName(array $existingModules, The
100103
101104 $ this ->warn ("The following modules already exist with the same name: " );
102105 foreach ($ existingModules as $ folder => $ module ) {
103- $ this ->line ("{$ module ->name } ( {$ folder }: {$ module ->version }) - {$ module ->description }" );
106+ $ this ->line ("{$ module ->name } ( {$ folder }: {$ module ->getVersion () }) - {$ module ->description }" );
104107 }
105108 $ this ->line ('' );
106109
@@ -145,7 +148,7 @@ protected function getModuleFolder(string $themeFolder): string|null
145148 protected function getThemeFolder (): string |null
146149 {
147150 $ path = theme_path ('' );
148- if (!$ path ) {
151+ if (!$ path || ! is_dir ( $ path ) ) {
149152 $ shouldCreate = $ this ->confirm ('No active theme folder found, would you like to create one? ' );
150153 if (!$ shouldCreate ) {
151154 return null ;
@@ -178,7 +181,7 @@ protected function validateAndGetModuleInfoFromZip(ThemeModuleZip $zip): ThemeMo
178181 }
179182
180183 if ($ zip ->getContentsSize () > (50 * 1024 * 1024 )) {
181- $ this ->error ("ERROR: Module ZIP file is too large. Maximum size is 50MB " );
184+ $ this ->error ("ERROR: Module ZIP file contents are too large. Maximum size is 50MB " );
182185 return null ;
183186 }
184187
@@ -196,7 +199,7 @@ protected function downloadModuleFile(string $location): string|null
196199 {
197200 $ httpRequests = app ()->make (HttpRequestService::class);
198201 $ client = $ httpRequests ->buildClient (30 , ['stream ' => true ]);
199- $ originalHost = parse_url ($ location, PHP_URL_HOST );
202+ $ originalUrl = parse_url ($ location );
200203 $ currentLocation = $ location ;
201204 $ maxRedirects = 3 ;
202205 $ redirectCount = 0 ;
@@ -209,8 +212,12 @@ protected function downloadModuleFile(string $location): string|null
209212 if ($ statusCode >= 300 && $ statusCode < 400 && $ redirectCount < $ maxRedirects ) {
210213 $ redirectLocation = $ resp ->getHeaderLine ('Location ' );
211214 if ($ redirectLocation ) {
212- $ redirectHost = parse_url ($ redirectLocation , PHP_URL_HOST );
213- if ($ redirectHost === $ originalHost ) {
215+ $ redirectUrl = parse_url ($ redirectLocation );
216+ if (
217+ ($ originalUrl ['host ' ] ?? '' ) === ($ redirectUrl ['host ' ] ?? '' )
218+ && ($ originalUrl ['scheme ' ] ?? '' ) === ($ redirectUrl ['scheme ' ] ?? '' )
219+ && ($ originalUrl ['port ' ] ?? '' ) === ($ redirectUrl ['port ' ] ?? '' )
220+ ) {
214221 $ currentLocation = $ redirectLocation ;
215222 $ redirectCount ++;
216223 continue ;
0 commit comments