[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] tiki-check.php: Add short timeout for Composer availability check

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69d02fa8423b_3b1905141001a5@gitlab-sidekiq-low-urgency-cpu-bound-v2-7687f47b56-sw4q2.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
57a32095 by Moïse Nturubika at 2026-04-03T21:15:18+00:00
[FIX] tiki-check.php: Add short timeout for Composer availability check
---
* [FIX] Composer: Improve timeout detection and error diagnostics in tiki-check

* [FIX] ComposerCli: Clamp process timeout to prevent silent fatal errors

* [FIX] tiki-check.php: Add short timeout for Composer availability check

See merge request tikiwiki/tiki!9417

- - - - -


2 changed files:

- lib/core/Tiki/Package/ComposerCli.php
- tiki-check.php


Changes:

=====================================
lib/core/Tiki/Package/ComposerCli.php
=====================================
@@ -213,7 +213,7 @@ class ComposerCli
         $canExecute = false;
 
         if ($this->composerPharExists()) {
-            list($output) = $this->execComposer(['--no-ansi', '--version']);
+            list($output) = $this->execComposer(['--no-ansi', '--version'], 5);
             if (strncmp($output, 'Composer', 8) == 0) {
                 $canExecute = true;
             }
@@ -236,9 +236,10 @@ class ComposerCli
      * Execute Composer
      *
      * @param $args
+     * @param int|null $timeout
      * @return array
      */
-    protected function execComposer($args)
+    protected function execComposer($args, $timeout = null)
     {
         global $prefs;
 
@@ -271,7 +272,29 @@ class ComposerCli
 
             $process = new Process($args, null, $env);
             $command = $process->getCommandLine();
-            $process->setTimeout($this->timeout);
+            $timeout = $timeout ?? $this->timeout;
+
+            $maxExecutionTime = (int) ini_get('max_execution_time');
+            if ($maxExecutionTime > 0) {
+                $elapsed = 0;
+                if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
+                    $elapsed = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
+                } elseif (isset($_SERVER['REQUEST_TIME'])) {
+                    $elapsed = time() - $_SERVER['REQUEST_TIME'];
+                }
+
+                $remaining = $maxExecutionTime - $elapsed;
+                $safeTimeout = $remaining - 5;
+
+                if ($safeTimeout < 1) {
+                    $safeTimeout = 1;
+                }
+                if ($timeout > $safeTimeout) {
+                    $timeout = $safeTimeout;
+                }
+            }
+
+            $process->setTimeout($timeout);
             $process->run();
 
             $code = $process->getExitCode();


=====================================
tiki-check.php
=====================================
@@ -3487,11 +3487,22 @@ if (! $standalone) {
             'message' => tra('Composer found')
         );
     } else {
-        $composerChecks['composer'] = array(
-            'fitness' => tra('bad'),
-            'fitness_status' => FITNESS_STATUS_BAD,
-            'message' => tra('Composer not found')
-        );
+        $lastResult = $composerManager->getComposer()->getLastResult();
+        $isTimeout = $lastResult && stripos($lastResult['errors'], 'timeout') !== false;
+
+        if ($isTimeout) {
+            $composerChecks['composer'] = array(
+                'fitness' => tra('unsure'),
+                'fitness_status' => FITNESS_STATUS_UNSURE,
+                'message' => tra('Composer check timed out. This may indicate a system-level process blocking issue (e.g. antivirus scanning) or severe resource constraints.')
+            );
+        } else {
+            $composerChecks['composer'] = array(
+                'fitness' => tra('bad'),
+                'fitness_status' => FITNESS_STATUS_BAD,
+                'message' => tra('Composer not found')
+            );
+        }
     }
 
     if (extension_loaded('bz2')) {



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/57a3209503ec7abafa85c2b95fb002e320ecaf7f

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/57a3209503ec7abafa85c2b95fb002e320ecaf7f
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.