Skip to content

Commit 393ff59

Browse files
committed
B2B-2069: Images from remote directory is throwing errors on lib/internal/Magento/Framework/Filesystem/Directory/Write.php
- changes to ignore phpcs checks
1 parent d14a0e4 commit 393ff59

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Driver for AWS S3 IO operations.
2626
*
2727
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2829
*/
2930
class AwsS3 implements RemoteDriverInterface
3031
{
@@ -258,6 +259,7 @@ public function filePutContents($path, $content, $mode = null): int
258259
$path = $this->normalizeRelativePath($path, true);
259260
$config = self::CONFIG;
260261

262+
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
261263
if (false !== ($imageSize = @getimagesizefromstring($content))) {
262264
$config['Metadata'] = [
263265
'image-width' => $imageSize[0],
@@ -489,8 +491,7 @@ public function getRelativePath($basePath, $path = null): string
489491
$basePath = (string)$basePath;
490492
$path = (string)$path;
491493

492-
if (
493-
($basePath && $path)
494+
if ($basePath && $path
494495
&& ($basePath === $path . '/' || strpos($path, $basePath) === 0)
495496
) {
496497
$result = substr($path, strlen($basePath));
@@ -723,6 +724,7 @@ public function fileGetCsv($resource, $length = 0, $delimiter = ',', $enclosure
723724
*/
724725
public function fileTell($resource): int
725726
{
727+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
726728
$result = @ftell($resource);
727729
if ($result === null) {
728730
throw new FileSystemException(
@@ -738,6 +740,7 @@ public function fileTell($resource): int
738740
*/
739741
public function fileSeek($resource, $offset, $whence = SEEK_SET): int
740742
{
743+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
741744
$result = @fseek($resource, $offset, $whence);
742745
if ($result === -1) {
743746
throw new FileSystemException(
@@ -756,6 +759,7 @@ public function fileSeek($resource, $offset, $whence = SEEK_SET): int
756759
*/
757760
public function endOfFile($resource): bool
758761
{
762+
// phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
759763
return feof($resource);
760764
}
761765

@@ -773,6 +777,7 @@ public function filePutCsv($resource, array $data, $delimiter = ',', $enclosure
773777
*/
774778
public function fileFlush($resource): bool
775779
{
780+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
776781
$result = @fflush($resource);
777782
if (!$result) {
778783
throw new FileSystemException(
@@ -791,6 +796,7 @@ public function fileFlush($resource): bool
791796
*/
792797
public function fileLock($resource, $lockMode = LOCK_EX): bool
793798
{
799+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
794800
$result = @flock($resource, $lockMode);
795801
if (!$result) {
796802
throw new FileSystemException(
@@ -809,6 +815,7 @@ public function fileLock($resource, $lockMode = LOCK_EX): bool
809815
*/
810816
public function fileUnlock($resource): bool
811817
{
818+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
812819
$result = @flock($resource, LOCK_UN);
813820
if (!$result) {
814821
throw new FileSystemException(
@@ -852,13 +859,14 @@ public function fileClose($resource): bool
852859
//phpcs:enable
853860

854861
foreach ($this->streams as $path => $stream) {
855-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
862+
// phpcs:ignore
856863
if (stream_get_meta_data($stream)['uri'] === $resourcePath) {
857864
$this->adapter->writeStream($path, $resource, new Config(self::CONFIG));
858865

859866
// Remove path from streams after
860867
unset($this->streams[$path]);
861868

869+
// phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
862870
return fclose($stream);
863871
}
864872
}
@@ -932,6 +940,7 @@ private function readPath(string $path, $isRecursive = false): array
932940
if (!empty($path)
933941
&& $path !== $relativePath
934942
&& (!$relativePath || strpos($path, $relativePath) === 0)) {
943+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
935944
$itemsList[] = $this->getAbsolutePath(dirname($path), $path);
936945
}
937946
}

app/code/Magento/Customer/Model/Metadata/Form/Image.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ protected function _validateByRules($value)
140140
$rules = $this->getAttribute()->getValidationRules();
141141

142142
try {
143+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
143144
$imageProp = getimagesize($value['tmp_name']);
144145
} catch (\Throwable $e) {
145146
$imageProp = false;

0 commit comments

Comments
 (0)