From cfc98cf2286738e798ed6142c0b01cf39f8904a8 Mon Sep 17 00:00:00 2001 From: Digital Pianism Date: Thu, 11 Mar 2021 02:13:24 +0100 Subject: [PATCH] Fix a bug where product media upload via API was not possible anymore. (#1302) * bump version * Fix _addUrlRewrite() ignoring collection store scope. (#510) While Mage_Catalog_Model_Resource_Product_Collection::addUrlRewrite() does respect any set storeId on the collection it's helper that does the actual work is hard-coded to the current active store. * Add doc comments to image related classes (#1146) * Prevent duplicate entry when updating salesrule_coupon_usage (#1117) * remove $timesUsed > 0 check to prevent duplicate entry * Prevent $timesUsed from going less than 0 * Fix a bug where media upload via API are not possible anymore: #1178 * revert unwanted changes * Update lib/Varien/Io/File.php Co-authored-by: Flyingmana Co-authored-by: Colin Mollenhour Co-authored-by: Erik Dannenberg Co-authored-by: Tymoteusz Motylewski Co-authored-by: Dean Williams Co-authored-by: sv3n --- lib/Varien/Io/File.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Varien/Io/File.php b/lib/Varien/Io/File.php index 0cf379b33f3..052df5cca65 100644 --- a/lib/Varien/Io/File.php +++ b/lib/Varien/Io/File.php @@ -486,8 +486,12 @@ public function write($filename, $src, $mode=null) */ protected function _IsValidSource($src) { - //Treat string that contains a null byte as invalid - if ((is_string($src) && strpos($src, chr(0)) === false) || is_resource($src)) { + // In case of a string + if (is_string($src)) { + // If its a file we check for null byte + // If it's not a valid path, file_exists() will return a falsey value, and the @ will keep it from complaining about the bad string. + return !(@file_exists($src) && strpos($src, chr(0)) !== false); + } elseif (is_resource($src)) { return true; } @@ -533,7 +537,7 @@ protected function _isFilenameWriteable($filename) protected function _checkSrcIsFile($src) { $result = false; - if (is_string($src) && is_readable($src) && is_file($src)) { + if (is_string($src) && @is_readable($src) && is_file($src)) { $result = true; }