Skip to content

Commit 3e3e8fc

Browse files
authored
Merge pull request #1850 from magento-performance/MAGETWO-81090
[PERFORMANCE] PAT Build improvement
2 parents 4d4e88a + 2dbf782 commit 3e3e8fc

File tree

24 files changed

+24006
-23186
lines changed

24 files changed

+24006
-23186
lines changed

app/code/Magento/Catalog/Block/Product/ImageBuilder.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Block\Product;
77

88
use Magento\Catalog\Helper\ImageFactory as HelperFactory;
9+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
910

1011
class ImageBuilder
1112
{
@@ -129,7 +130,11 @@ public function create()
129130
? 'Magento_Catalog::product/image.phtml'
130131
: 'Magento_Catalog::product/image_with_borders.phtml';
131132

132-
$imagesize = $helper->getResizedImageInfo();
133+
try {
134+
$imagesize = $helper->getResizedImageInfo();
135+
} catch (NotLoadInfoImageException $exception) {
136+
$imagesize = [$helper->getWidth(), $helper->getHeight()];
137+
}
133138

134139
$data = [
135140
'data' => [
@@ -140,8 +145,8 @@ public function create()
140145
'label' => $helper->getLabel(),
141146
'ratio' => $this->getRatio($helper),
142147
'custom_attributes' => $this->getCustomAttributes(),
143-
'resized_image_width' => !empty($imagesize[0]) ? $imagesize[0] : $helper->getWidth(),
144-
'resized_image_height' => !empty($imagesize[1]) ? $imagesize[1] : $helper->getHeight(),
148+
'resized_image_width' => $imagesize[0],
149+
'resized_image_height' => $imagesize[1],
145150
],
146151
];
147152

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model\Product;
77

8+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
89
use Magento\Framework\App\Filesystem\DirectoryList;
910
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Image as MagentoImage;
@@ -877,17 +878,26 @@ protected function _fileExists($filename)
877878

878879
/**
879880
* Return resized product image information
880-
*
881881
* @return array
882+
* @throws NotLoadInfoImageException
882883
*/
883884
public function getResizedImageInfo()
884885
{
885-
if ($this->isBaseFilePlaceholder() == true) {
886-
$image = $this->imageAsset->getSourceFile();
887-
} else {
888-
$image = $this->imageAsset->getPath();
886+
try {
887+
if ($this->isBaseFilePlaceholder() == true) {
888+
$image = $this->imageAsset->getSourceFile();
889+
} else {
890+
$image = $this->imageAsset->getPath();
891+
}
892+
893+
$imageProperties = getimagesize($image);
894+
895+
return $imageProperties;
896+
} finally {
897+
if (empty($imageProperties)) {
898+
throw new NotLoadInfoImageException(__('Can\'t get information about the picture: %1', $image));
899+
}
889900
}
890-
return getimagesize($image);
891901
}
892902

893903
/**
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Product\Image;
7+
8+
class NotLoadInfoImageException extends \Exception
9+
{
10+
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Catalog\Api\Data\ProductRender\ImageInterfaceFactory;
1212
use Magento\Catalog\Api\Data\ProductRenderInterface;
1313
use Magento\Catalog\Helper\ImageFactory;
14+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
1415
use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorInterface;
1516
use Magento\Framework\App\State;
1617
use Magento\Framework\View\DesignInterface;
@@ -102,7 +103,12 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
102103
[$this, "emulateImageCreating"],
103104
[$product, $imageCode, (int) $productRender->getStoreId(), $image]
104105
);
105-
$resizedInfo = $helper->getResizedImageInfo();
106+
107+
try {
108+
$resizedInfo = $helper->getResizedImageInfo();
109+
} catch (NotLoadInfoImageException $exception) {
110+
$resizedInfo = [$helper->getWidth(), $helper->getHeight()];
111+
}
106112

107113
$image->setCode($imageCode);
108114
$image->setHeight($helper->getHeight());

app/code/Magento/Wishlist/CustomerData/Wishlist.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Wishlist\CustomerData;
77

8+
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
89
use Magento\Customer\CustomerData\SectionSourceInterface;
910

1011
/**
@@ -154,15 +155,19 @@ protected function getImageData($product)
154155
? 'Magento_Catalog/product/image'
155156
: 'Magento_Catalog/product/image_with_borders';
156157

157-
$imagesize = $helper->getResizedImageInfo();
158+
try {
159+
$imagesize = $helper->getResizedImageInfo();
160+
} catch (NotLoadInfoImageException $exception) {
161+
$imagesize = [$helper->getWidth(), $helper->getHeight()];
162+
}
158163

159164
$width = $helper->getFrame()
160165
? $helper->getWidth()
161-
: (!empty($imagesize[0]) ? $imagesize[0] : $helper->getWidth());
166+
: $imagesize[0];
162167

163168
$height = $helper->getFrame()
164169
? $helper->getHeight()
165-
: (!empty($imagesize[1]) ? $imagesize[1] : $helper->getHeight());
170+
: $imagesize[1];
166171

167172
return [
168173
'template' => $template,

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixtureModelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testFixtureGeneration()
118118

119119
foreach ($this->entityAsserts as $entityAssert) {
120120
try {
121-
$entityAssert->assert();
121+
$this->assertTrue($entityAssert->assert());
122122
} catch (\AssertionError $assertionError) {
123123
$this->assertTrue(false, $assertionError->getMessage());
124124
}

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/BundleProductsAssert.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(
4848
/**
4949
* Asserts that generated bundled products are valid
5050
*
51-
* @return void
51+
* @return bool
5252
* @throws \Magento\Framework\Exception\NoSuchEntityException
5353
* @throws \AssertionError
5454
*/
@@ -74,5 +74,7 @@ public function assert()
7474
throw new \AssertionError('Bundle option product links amount is wrong');
7575
}
7676
}
77+
78+
return true;
7779
}
7880
}

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/ConfigurableProductsAssert.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(
4646
/**
4747
* Asserts that generated configurable products are valid
4848
*
49-
* @return void
49+
* @return bool
5050
* @throws \Magento\Framework\Exception\NoSuchEntityException
5151
* @throws \Magento\Framework\Exception\InputException
5252
* @throws \AssertionError
@@ -86,5 +86,7 @@ public function assert()
8686
throw new \AssertionError('Configurable option values amount is wrong');
8787
}
8888
}
89+
90+
return true;
8991
}
9092
}

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/ImagesAssert.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function __construct(
7070
/**
7171
* Performs assertions over images
7272
*
73+
* @return bool
7374
* @throws \AssertionError
7475
*/
7576
public function assert()
@@ -82,6 +83,8 @@ public function assert()
8283
$this->assertProductMediaAttributes($product);
8384
$this->assertProductImageExistsInFS($product);
8485
}
86+
87+
return true;
8588
}
8689

8790
/**

dev/tests/integration/testsuite/Magento/Setup/Fixtures/FixturesAsserts/SimpleProductsAssert.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(
4343
/**
4444
* Asserts that generated simple products are valid
4545
*
46-
* @return void
46+
* @return bool
4747
* @throws \Magento\Framework\Exception\NoSuchEntityException
4848
* @throws \AssertionError
4949
*/
@@ -52,5 +52,7 @@ public function assert()
5252
$product = $this->productRepository->get(sprintf(SimpleProductsFixture::SKU_PATTERN, 1));
5353
$this->productAssert->assertProductsCount(SimpleProductsFixture::SKU_PATTERN, 2);
5454
$this->productAssert->assertProductType('simple', $product);
55+
56+
return true;
5557
}
5658
}

dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
\Magento\Framework\DB\FieldDataConversionException
1212
\Magento\Signifyd\Model\SignifydGateway\GatewayException
1313
\Magento\Signifyd\Model\SignifydGateway\ApiCallException
14+
\Magento\Catalog\Model\Product\Image\NotLoadInfoImageException

setup/performance-toolkit/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The following parameters can be passed to the `benchmark.jmx` scenario:
6262
| admin_user | admin | Admin backend user. |
6363
| admin_password | 123123q | Admin backend password. |
6464
| customer_password | 123123q | Storefront customer password. |
65-
| customers_page_size | 20 | Page size for customers grid in Magento Admin. |
65+
| customers_page_size | 50 | Page size for customers grid in Magento Admin. |
6666
| files_folder | ./files/ | Path to various files that are used in scenario (`setup/performance-toolkit/files`). |
6767
| loops | 1 | Number of loops to run. |
6868
| frontendPoolUsers | 1 | Total number of Frontend threads. |

0 commit comments

Comments
 (0)