Skip to content

Commit cfc98cf

Browse files
Digital PianismFlyingmanacolinmollenhouredannenbergtmotyl
authored
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 <flyingmana@googlemail.com> Co-authored-by: Colin Mollenhour <colin@mollenhour.com> Co-authored-by: Erik Dannenberg <ed@reshape.de> Co-authored-by: Tymoteusz Motylewski <t.motylewski@gmail.com> Co-authored-by: Dean Williams <me@deanwilliams.org> Co-authored-by: sv3n <github-sr@hotmail.com>
1 parent 08d41c2 commit cfc98cf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/Varien/Io/File.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,12 @@ public function write($filename, $src, $mode=null)
486486
*/
487487
protected function _IsValidSource($src)
488488
{
489-
//Treat string that contains a null byte as invalid
490-
if ((is_string($src) && strpos($src, chr(0)) === false) || is_resource($src)) {
489+
// In case of a string
490+
if (is_string($src)) {
491+
// If its a file we check for null byte
492+
// 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.
493+
return !(@file_exists($src) && strpos($src, chr(0)) !== false);
494+
} elseif (is_resource($src)) {
491495
return true;
492496
}
493497

@@ -533,7 +537,7 @@ protected function _isFilenameWriteable($filename)
533537
protected function _checkSrcIsFile($src)
534538
{
535539
$result = false;
536-
if (is_string($src) && is_readable($src) && is_file($src)) {
540+
if (is_string($src) && @is_readable($src) && is_file($src)) {
537541
$result = true;
538542
}
539543

0 commit comments

Comments
 (0)