Add WORKER_STATUS_FD to WorkerCLICommand
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 1 Jul 2020 09:48:58 +0000 (11:48 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 2 Jul 2020 10:50:51 +0000 (12:50 +0200)
wcfsetup/install/files/lib/system/cli/command/WorkerCLICommand.class.php

index 869d9f15d9bd17fd204c89468acbc0ca45ca8b42..d22226c73848dcb072ee9b489301e52bd571a3ea 100644 (file)
@@ -16,7 +16,7 @@ use Zend\ProgressBar\ProgressBar;
  * Executes cronjobs.
  * 
  * @author     Tim Duesterhus
- * @copyright  2001-2019 WoltLab GmbH
+ * @copyright  2001-2020 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    WoltLabSuite\Core\System\Cli\Command
  */
@@ -114,6 +114,10 @@ class WorkerCLICommand implements IArgumentedCLICommand {
                        'width' => CLIWCF::getTerminal()->getWidth()
                ]));
                $progress = 0;
+               $output = null;
+               if (!empty($_ENV['WORKER_STATUS_FD'])) {
+                       $output = new File("php://fd/".$_ENV['WORKER_STATUS_FD'], "w");
+               }
                for ($i = 0; $progress < 100; $i++) {
                        $worker->setLoopCount($i);
                        $worker->validate();
@@ -125,6 +129,13 @@ class WorkerCLICommand implements IArgumentedCLICommand {
                        // update progress
                        $progress = $worker->getProgress();
                        $progressbar->update($progress);
+                       if ($output) {
+                               $output->write("$i,$progress\n");
+                       }
+               }
+               if ($output) {
+                       $output->write("done,$progress");
+                       $output->close();
                }
                $progressbar->update($progress);