Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#2210 from weierophinne…
Browse files Browse the repository at this point in the history
…y/hotfix/remove-suppression-operator

Get rid of error suppression
  • Loading branch information
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/Transfer/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

namespace Zend\File\Transfer\Adapter;

use ErrorException;
use Zend\File\Transfer;
use Zend\File\Transfer\Exception;
use Zend\Filter;
use Zend\Filter\Exception as FilterException;
use Zend\I18n\Translator\Translator;
use Zend\I18n\Translator\TranslatorAwareInterface;
use Zend\Stdlib\ErrorHandler;
use Zend\Validator;

/**
Expand Down Expand Up @@ -1161,14 +1163,21 @@ public function getFileSize($files = null)
protected function detectFileSize($value)
{
if (file_exists($value['name'])) {
$result = sprintf("%u", @filesize($value['name']));
$filename = $value['name'];
} elseif (file_exists($value['tmp_name'])) {
$result = sprintf("%u", @filesize($value['tmp_name']));
$filename = $value['tmp_name'];
} else {
return null;
}

return $result;
ErrorHandler::start();
$filesize = filesize($filename);
$return = ErrorHandler::stop();
if ($return instanceof ErrorException) {
$filesize = 0;
}

return sprintf("%u", $filesize);
}

/**
Expand Down Expand Up @@ -1219,11 +1228,15 @@ protected function detectMimeType($value)
if (class_exists('finfo', false)) {
$const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
if (!empty($value['options']['magicFile'])) {
$mime = @finfo_open($const, $value['options']['magicFile']);
ErrorHandler::start();
$mime = finfo_open($const, $value['options']['magicFile']);
ErrorHandler::stop();
}

if (empty($mime)) {
$mime = @finfo_open($const);
ErrorHandler::start();
$mime = finfo_open($const);
ErrorHandler::stop();
}

if (!empty($mime)) {
Expand Down Expand Up @@ -1357,13 +1370,17 @@ protected function isPathWriteable($path)
$tempFile = rtrim($path, "/\\");
$tempFile .= '/' . 'test.1';

$result = @file_put_contents($tempFile, 'TEST');
ErrorHandler::start();
$result = file_put_contents($tempFile, 'TEST');
ErrorHandler::stop();

if ($result == false) {
return false;
}

$result = @unlink($tempFile);
ErrorHandler::start();
$result = unlink($tempFile);
ErrorHandler::stop();

if ($result == false) {
return false;
Expand Down

0 comments on commit f8bc057

Please sign in to comment.