Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Progress
File: Upload.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class MWP_Progress_Upload extends MWP_Progress_Abstract
[10] Fix | Delete
{
[11] Fix | Delete
/**
[12] Fix | Delete
* @var int
[13] Fix | Delete
*/
[14] Fix | Delete
private $fileSize;
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* @var Monolog_Psr_LoggerInterface
[18] Fix | Delete
*/
[19] Fix | Delete
private $logger;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* @var int
[23] Fix | Delete
*/
[24] Fix | Delete
private $lastProgress = 0;
[25] Fix | Delete
[26] Fix | Delete
public function __construct($fileSize, $threshold, Monolog_Psr_LoggerInterface $logger)
[27] Fix | Delete
{
[28] Fix | Delete
$this->fileSize = $fileSize;
[29] Fix | Delete
$this->setThreshold($threshold);
[30] Fix | Delete
$this->logger = $logger;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
public function callback(&$curl, $downloadSize, $downloadedSize, $uploadSize, $uploadedSize = 0)
[34] Fix | Delete
{
[35] Fix | Delete
if (!$this->yieldCallback()) {
[36] Fix | Delete
return;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
if (func_num_args() < 5) {
[40] Fix | Delete
$uploadedSize = $uploadSize;
[41] Fix | Delete
$uploadSize = $downloadedSize;
[42] Fix | Delete
$downloadedSize = $downloadSize;
[43] Fix | Delete
$downloadSize = $curl;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
$offset = is_resource($curl) ? $this->calculateOffset($curl) : 0;
[47] Fix | Delete
$currentProgress = $uploadedSize + $offset;
[48] Fix | Delete
$speed = $this->formatBytes(($currentProgress - $this->lastProgress) / $this->getThreshold());
[49] Fix | Delete
$this->lastProgress = $currentProgress;
[50] Fix | Delete
[51] Fix | Delete
$progress = round($currentProgress / $this->fileSize * 100, 2);
[52] Fix | Delete
[53] Fix | Delete
global $forkedRequest;
[54] Fix | Delete
if (!$forkedRequest) {
[55] Fix | Delete
echo " ";
[56] Fix | Delete
flush();
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
$this->logger->info(
[60] Fix | Delete
'Upload progress: {progress}% (speed: {speed}/s)',
[61] Fix | Delete
array(
[62] Fix | Delete
'progress' => $progress,
[63] Fix | Delete
'speed' => $speed,
[64] Fix | Delete
)
[65] Fix | Delete
);
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function