@@ -146,8 +146,16 @@ private function getNodeVersion(): string
146146 private function getLatestLtsNodeVersion (): string
147147 {
148148 try {
149- $ nodeData = file_get_contents (self ::NODE_LTS_URL );
150- if ($ nodeData === false ) {
149+ $ httpClient = $ this ->httpClientFactory ->create ();
150+ $ httpClient ->setTimeout (2 );
151+ $ httpClient ->get (self ::NODE_LTS_URL );
152+
153+ if ($ httpClient ->getStatus () !== 200 ) {
154+ return 'Unknown ' ;
155+ }
156+
157+ $ nodeData = $ httpClient ->getBody ();
158+ if ($ nodeData === '' ) {
151159 return 'Unknown ' ;
152160 }
153161
@@ -163,6 +171,9 @@ private function getLatestLtsNodeVersion(): string
163171 }
164172 return 'Unknown ' ;
165173 } catch (\Exception $ e ) {
174+ if ($ this ->io ->isVerbose ()) {
175+ $ this ->io ->warning ('Failed to fetch latest Node.js LTS version: ' . $ e ->getMessage ());
176+ }
166177 return 'Unknown ' ;
167178 }
168179 }
@@ -185,11 +196,6 @@ private function getShortMysqlVersion(): string
185196 return $ version ;
186197 }
187198
188- $ version = $ this ->getMysqlVersionViaPdo ();
189- if (!empty ($ version )) {
190- return $ version ;
191- }
192-
193199 return 'Unknown ' ;
194200 }
195201
@@ -202,10 +208,14 @@ private function getMysqlVersionViaMagento(): ?string
202208 {
203209 try {
204210 $ connection = $ this ->resourceConnection ->getConnection ();
205- $ version = $ connection ->fetchOne ('SELECT VERSION() ' );
211+ $ select = $ connection ->select ()->from (null , new \Zend_Db_Expr ('VERSION() ' ));
212+ $ version = $ connection ->fetchOne ($ select );
206213
207214 return !empty ($ version ) ? $ version : null ;
208215 } catch (\Exception $ e ) {
216+ if ($ this ->io ->isVerbose ()) {
217+ $ this ->io ->warning ('Failed to read MySQL version via Magento connection: ' . $ e ->getMessage ());
218+ }
209219 return null ;
210220 }
211221 }
@@ -220,6 +230,9 @@ private function getMysqlVersionViaClient(): ?string
220230 try {
221231 $ output = trim ($ this ->shell ->execute ('mysql --version 2>/dev/null ' ));
222232 } catch (\Exception $ e ) {
233+ if ($ this ->io ->isVerbose ()) {
234+ $ this ->io ->warning ('Failed to read MySQL version via client: ' . $ e ->getMessage ());
235+ }
223236 return null ;
224237 }
225238
@@ -231,66 +244,6 @@ private function getMysqlVersionViaClient(): ?string
231244 return null ;
232245 }
233246
234- /**
235- * Get MySQL version via PDO connection
236- *
237- * @return string|null
238- */
239- private function getMysqlVersionViaPdo (): ?string
240- {
241- try {
242- $ config = $ this ->getDatabaseConfig ();
243-
244- // Default values if nothing is found
245- $ host = $ config ['host ' ] ?? 'localhost ' ;
246- $ port = $ config ['port ' ] ?? '3306 ' ;
247- $ user = $ config ['user ' ] ?? 'root ' ;
248- $ pass = $ config ['pass ' ] ?? '' ;
249-
250- $ dsn = "mysql:host= $ host;port= $ port " ;
251- $ pdo = new \PDO ($ dsn , $ user , $ pass , [\PDO ::ATTR_TIMEOUT => 1 ]);
252- $ stmt = $ pdo ->query ('SELECT VERSION() ' );
253- if ($ stmt === false ) {
254- return null ;
255- }
256-
257- $ version = $ stmt ->fetchColumn ();
258-
259- return !empty ($ version ) ? (string )$ version : null ;
260- } catch (\Exception $ e ) {
261- return null ;
262- }
263- }
264-
265- /**
266- * Get database configuration from environment variables
267- *
268- * @return array<string, string>
269- */
270- private function getDatabaseConfig (): array
271- {
272- $ envMapping = [
273- 'host ' => ['DB_HOST ' , 'MYSQL_HOST ' , 'MAGENTO_DB_HOST ' ],
274- 'port ' => ['DB_PORT ' , 'MYSQL_PORT ' , 'MAGENTO_DB_PORT ' , '3306 ' ],
275- 'user ' => ['DB_USER ' , 'MYSQL_USER ' , 'MAGENTO_DB_USER ' ],
276- 'pass ' => ['DB_PASSWORD ' , 'MYSQL_PASSWORD ' , 'MAGENTO_DB_PASSWORD ' ],
277- 'name ' => ['DB_NAME ' , 'MYSQL_DATABASE ' , 'MAGENTO_DB_NAME ' ],
278- ];
279-
280- $ config = [];
281- foreach ($ envMapping as $ key => $ envVars ) {
282- foreach ($ envVars as $ env ) {
283- $ value = $ this ->getEnvironmentVariable ($ env );
284- if ($ value !== null ) {
285- $ config [$ key ] = $ value ;
286- break ;
287- }
288- }
289- }
290-
291- return $ config ;
292- }
293-
294247 /**
295248 * Get database type
296249 *
@@ -439,7 +392,9 @@ private function getSearchEngineFromMagentoConfig(): ?string
439392 return $ resolverResult ;
440393 }
441394 } catch (\Exception $ e ) {
442- // Ignore general exceptions
395+ if ($ this ->io ->isVerbose ()) {
396+ $ this ->io ->warning ('Failed to read search engine config from Magento: ' . $ e ->getMessage ());
397+ }
443398 }
444399
445400 return null ;
@@ -469,7 +424,9 @@ private function checkSearchEngineViaDeploymentConfig($objectManager): ?string
469424 return ucfirst ($ engineConfig ) . ' (Configured but not reachable) ' ;
470425 }
471426 } catch (\Exception $ e ) {
472- // Ignore specific exceptions
427+ if ($ this ->io ->isVerbose ()) {
428+ $ this ->io ->warning ('Failed to read search engine from deployment config: ' . $ e ->getMessage ());
429+ }
473430 }
474431
475432 return null ;
@@ -492,7 +449,9 @@ private function checkSearchEngineViaEngineResolver($objectManager): ?string
492449 }
493450 }
494451 } catch (\Exception $ e ) {
495- // Ignore specific exceptions
452+ if ($ this ->io ->isVerbose ()) {
453+ $ this ->io ->warning ('Failed to read search engine via resolver: ' . $ e ->getMessage ());
454+ }
496455 }
497456
498457 return null ;
@@ -533,7 +492,9 @@ private function checkSearchEngineConnections(): ?string
533492 }
534493 }
535494 } catch (\Exception $ e ) {
536- // Ignore
495+ if ($ this ->io ->isVerbose ()) {
496+ $ this ->io ->warning ('Failed to check search engine connections: ' . $ e ->getMessage ());
497+ }
537498 }
538499
539500 return null ;
@@ -573,7 +534,8 @@ private function getSearchEngineHosts(): array
573534 /**
574535 * Format search engine version output
575536 *
576- * @param array<string, mixed> $info
537+ * @param array $info
538+ * @phpstan-param array<string, mixed> $info
577539 * @return string
578540 */
579541 private function formatSearchEngineVersion (array $ info ): string
@@ -607,7 +569,9 @@ private function testElasticsearchConnection(string $url)
607569 // No fallback to native approaches anymore - rely on Magento's HTTP client only
608570 // This avoids using discouraged functions
609571 } catch (\Exception $ e ) {
610- // Ignore exceptions and return false
572+ if ($ this ->io ->isVerbose ()) {
573+ $ this ->io ->warning ('Search engine connection check failed: ' . $ e ->getMessage ());
574+ }
611575 }
612576
613577 return false ;
@@ -636,7 +600,9 @@ private function tryMagentoHttpClient(string $url): ?array
636600 }
637601 }
638602 } catch (\Exception $ e ) {
639- // Ignore exceptions
603+ if ($ this ->io ->isVerbose ()) {
604+ $ this ->io ->warning ('HTTP client request failed for search engine: ' . $ e ->getMessage ());
605+ }
640606 }
641607
642608 return null ;
@@ -738,7 +704,9 @@ private function getMagentoEnvironmentValue(string $name): ?string
738704 return $ serviceValue ;
739705 }
740706 } catch (\Exception $ e ) {
741- // Ignore exceptions
707+ if ($ this ->io ->isVerbose ()) {
708+ $ this ->io ->warning ('Failed to read Magento environment value: ' . $ e ->getMessage ());
709+ }
742710 }
743711
744712 return null ;
@@ -760,7 +728,9 @@ private function getValueFromDeploymentConfig($objectManager, string $name): ?st
760728 return (string )$ envValue ;
761729 }
762730 } catch (\Exception $ e ) {
763- // Ignore exceptions
731+ if ($ this ->io ->isVerbose ()) {
732+ $ this ->io ->warning ('Failed to read environment from deployment config: ' . $ e ->getMessage ());
733+ }
764734 }
765735
766736 return null ;
@@ -785,7 +755,9 @@ private function getValueFromEnvironmentService($objectManager, string $name): ?
785755 }
786756 }
787757 } catch (\Exception $ e ) {
788- // Ignore exceptions
758+ if ($ this ->io ->isVerbose ()) {
759+ $ this ->io ->warning ('Failed to read environment from service: ' . $ e ->getMessage ());
760+ }
789761 }
790762
791763 return null ;
0 commit comments