Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Session File Upload Progress fixes: Missing session key, Division by …

…zero
  • Loading branch information...
commit 80cb928f81eb2ee83343b22c702d38b084c4749f 1 parent 3c1f321
@cgmartin authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 library/Zend/ProgressBar/Upload/SessionProgress.php
View
13 library/Zend/ProgressBar/Upload/SessionProgress.php
@@ -35,7 +35,8 @@ protected function getUploadProgress($id)
);
}
- $uploadInfo = $_SESSION[ini_get('session.upload_progress.prefix') . $id];
+ $sessionKey = ini_get('session.upload_progress.prefix') . $id;
+ $uploadInfo = (isset($_SESSION[$sessionKey])) ? $_SESSION[$sessionKey] : null;
if (!is_array($uploadInfo)) {
return false;
}
@@ -45,12 +46,15 @@ protected function getUploadProgress($id)
'current' => 0,
'rate' => 0,
'message' => '',
- 'done' => false
+ 'done' => false,
);
$status = $uploadInfo + $status;
$status['total'] = $status['content_length'];
$status['current'] = $status['bytes_processed'];
- $status['rate'] = $status['bytes_processed'] / (time() - $status['start_time']);
+
+ $time = time() - $status['start_time'];
+ $status['rate'] = ($time > 0) ? $status['bytes_processed'] / $time : 0;
+
if (!empty($status['cancel_upload'])) {
$status['done'] = true;
$status['message'] = 'The upload has been canceled';
@@ -66,7 +70,6 @@ protected function getUploadProgress($id)
*/
public function isSessionUploadProgressAvailable()
{
- return (bool) version_compare(PHP_VERSION, '5.4.0rc1', '>=')
- && (bool) ini_get('session.upload_progress.enabled');
+ return (bool) ini_get('session.upload_progress.enabled');
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.