From: Alexander Ebert Date: Wed, 14 Sep 2011 13:45:15 +0000 (+0200) Subject: Fixed worker progress (calculation mismatch) X-Git-Tag: 2.0.0_Beta_1~1765^2~14 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ffbd2df6b510b1544dd621690866fae56e4bdd7c;p=GitHub%2FWoltLab%2FWCF.git Fixed worker progress (calculation mismatch) --- diff --git a/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php b/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php index 3bb3f904ad..ac0268b45b 100644 --- a/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/WorkerProxyAction.class.php @@ -28,7 +28,7 @@ class WorkerProxyAction extends AbstractSecureAction { * loop counter * @var integer */ - protected $loopCount = 0; + protected $loopCount = -1; /** * parameters for worker action @@ -91,21 +91,22 @@ class WorkerProxyAction extends AbstractSecureAction { public function execute() { parent::execute(); - // initialize worker - if ($this->loopCount == 0) { + if ($this->loopCount == -1) { $this->sendResponse(); } + // init worker $this->worker = new $this->className($this->parameters); $this->worker->setLoopCount($this->loopCount); + + // validate worker parameters $this->worker->validate(); - $returnValues = array(); + // calculate progress, triggers countObjects() $progress = $this->worker->getProgress(); - $returnValues['progress'] = $progress; - if ($progress < 100) { - $this->worker->execute(); - } + + // execute worker + $this->worker->execute(); // send current state $this->sendResponse($progress, $this->worker->getParameters()); @@ -124,13 +125,13 @@ class WorkerProxyAction extends AbstractSecureAction { // build return values $returnValues = array( 'className' => $this->className, - 'loopCount' => $this->loopCount, + 'loopCount' => ($this->loopCount + 1), 'parameters' => $parameters, 'progress' => $progress ); // include template on startup - if ($progress == 0) { + if ($this->loopCount == -1) { $returnValues['template'] = WCF::getTPL()->fetch('worker'); } diff --git a/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php b/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php index 7c65c8a7dc..bd6c43a3c1 100644 --- a/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php +++ b/wcfsetup/install/files/lib/system/worker/AbstractWorker.class.php @@ -65,7 +65,8 @@ abstract class AbstractWorker implements IWorker { return 100; } - return ceil(($this->loopCount / ceil($this->count / $this->limit)) * 100); + $progress = (($this->limit * ($this->loopCount + 1)) / $this->count) * 100; + return round($progress, 0); } /**