diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index cbbd05a80f0438e0d69826c1635b3f469cefae40..3ac68076d43538c20376d16eba4802d7673aec54 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,16 +1,24 @@ -Steps to reproduce --- -1. Install Magento from `develop` branch. -2. [Example] Add Configurable Product to the cart. -3. ... +<!--- Provide a general summary of the issue in the Title above --> +<!--- Before adding new issues, please, check this article https://github.com/magento/magento2/wiki/Issue-reporting-guidelines--> -Expected result --- -1. [Example] Configurable product added to the shopping cart. -2. ... +### Preconditions +<!--- Provide a more detailed information of environment you use --> +<!--- Magento version, tag, HEAD, etc., PHP & MySQL version, etc.. --> +1. +2. -Actual result --- -1. [Example] Error message appears: "Cannot save quote". -2. [Screenshot, logs] -3. ... +### Steps to reproduce +<!--- Provide a set of unambiguous steps to reproduce this bug include code, if relevant --> +1. +2. +3. + +### Expected result +<!--- Tell us what should happen --> +1. + +### Actual result +<!--- Tell us what happens instead --> +1. [Screenshot, logs] + +<!--- (This may be platform independent comment) --> diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php index f61f9071155aa915d3d06e4ef66fa0de29fa100f..262ba8cccc27e0e8ee179dc64ae59e0366c9e21f 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Gallery/Content.php @@ -16,6 +16,7 @@ namespace Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery; use Magento\Backend\Block\Media\Uploader; use Magento\Framework\View\Element\AbstractBlock; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\FileSystemException; class Content extends \Magento\Backend\Block\Widget { @@ -34,6 +35,16 @@ class Content extends \Magento\Backend\Block\Widget */ protected $_jsonEncoder; + /** + * @var \Magento\Catalog\Helper\Image + */ + private $imageHelper; + + /** + * @var \Magento\Framework\View\Asset\Repository + */ + private $assetRepo; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder @@ -128,12 +139,22 @@ class Content extends \Magento\Backend\Block\Widget is_array($value['images']) && count($value['images']) ) { - $directory = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA); + $mediaDir = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA); $images = $this->sortImagesByPosition($value['images']); foreach ($images as &$image) { $image['url'] = $this->_mediaConfig->getMediaUrl($image['file']); - $fileHandler = $directory->stat($this->_mediaConfig->getMediaPath($image['file'])); - $image['size'] = $fileHandler['size']; + try { + $fileHandler = $mediaDir->stat($this->_mediaConfig->getMediaPath($image['file'])); + $image['size'] = $fileHandler['size']; + } catch (FileSystemException $e) { + $staticDir = $this->_filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW); + $image['url'] = $this->getImageHelper()->getDefaultPlaceholderUrl('thumbnail'); + $fileHandler = $staticDir->stat( + $this->getAssetRepo()->createAsset($this->getImageHelper()->getPlaceholder('thumbnail'))->getPath() + ); + $image['size'] = $fileHandler['size']; + $this->_logger->warning($e); + } } return $this->_jsonEncoder->encode($images); } @@ -227,4 +248,31 @@ class Content extends \Magento\Backend\Block\Widget { return $this->_jsonEncoder->encode($this->getImageTypes()); } + + /** + * @return \Magento\Catalog\Helper\Image + * @deprecated + */ + private function getImageHelper() + { + if ($this->imageHelper === null) { + $this->imageHelper = \Magento\Framework\App\ObjectManager::getInstance() + ->get('Magento\Catalog\Helper\Image'); + } + return $this->imageHelper; + } + + /** + * @return \Magento\Framework\View\Asset\Repository + * @deprecated + */ + private function getAssetRepo() + { + if ($this->assetRepo === null) { + $this->assetRepo = \Magento\Framework\App\ObjectManager::getInstance() + ->get('\Magento\Framework\View\Asset\Repository'); + } + + return $this->assetRepo; + } } diff --git a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php index 5ab2484348b0c05420cbef28713ed7385f01fa7e..5ea65f2ca608d7d744029a2ff54b8a9df2ac0ff5 100644 --- a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php +++ b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php @@ -118,4 +118,16 @@ class FinalPriceBox extends BasePriceBox && $minimalPriceAValue && $minimalPriceAValue < $finalPriceValue; } + + /** + * {@inheritdoc} + * + * @return array + */ + public function getCacheKeyInfo() + { + $cacheKeys = parent::getCacheKeyInfo(); + $cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice(); + return $cacheKeys; + } } diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php index 72a25933efa0be60c575128021c0a1816b4bfbe2..33faf5963c91014fa1bd7be34cf2dd961a87fe34 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Helper/Form/Gallery/ContentTest.php @@ -7,6 +7,7 @@ namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Helper\Form\Gallery; use Magento\Framework\Filesystem; use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content; +use Magento\Framework\Phrase; class ContentTest extends \PHPUnit_Framework_TestCase { @@ -40,6 +41,16 @@ class ContentTest extends \PHPUnit_Framework_TestCase */ protected $galleryMock; + /** + * @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject + */ + protected $imageHelper; + + /** + * @var \Magento\Framework\View\Asset\Repository|\PHPUnit_Framework_MockObject_MockObject + */ + protected $assetRepo; + /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ @@ -47,7 +58,13 @@ class ContentTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->fileSystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->fileSystemMock = $this->getMock( + 'Magento\Framework\Filesystem', + ['stat', 'getDirectoryRead'], + [], + '', + false + ); $this->readMock = $this->getMock('Magento\Framework\Filesystem\Directory\ReadInterface'); $this->galleryMock = $this->getMock( 'Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery', @@ -56,7 +73,13 @@ class ContentTest extends \PHPUnit_Framework_TestCase '', false ); - $this->mediaConfigMock = $this->getMock('Magento\Catalog\Model\Product\Media\Config', [], [], '', false); + $this->mediaConfigMock = $this->getMock( + 'Magento\Catalog\Model\Product\Media\Config', + ['getMediaUrl', 'getMediaPath'], + [], + '', + false + ); $this->jsonEncoderMock = $this->getMockBuilder('Magento\Framework\Json\EncoderInterface') ->disableOriginalConstructor() ->getMock(); @@ -130,7 +153,6 @@ class ContentTest extends \PHPUnit_Framework_TestCase $this->mediaConfigMock->expects($this->any())->method('getMediaUrl')->willReturnMap($url); $this->mediaConfigMock->expects($this->any())->method('getMediaPath')->willReturnMap($mediaPath); - $this->readMock->expects($this->any())->method('stat')->willReturnMap($sizeMap); $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode'); @@ -144,4 +166,92 @@ class ContentTest extends \PHPUnit_Framework_TestCase $this->assertSame('[]', $this->content->getImagesJson()); } + + public function testGetImagesJsonWithException() + { + $this->imageHelper = $this->getMockBuilder('Magento\Catalog\Helper\Image') + ->disableOriginalConstructor() + ->setMethods(['getDefaultPlaceholderUrl', 'getPlaceholder']) + ->getMock(); + + $this->assetRepo = $this->getMockBuilder('Magento\Framework\View\Asset\Repository') + ->disableOriginalConstructor() + ->setMethods(['createAsset', 'getPath']) + ->getMock(); + + $this->objectManager->setBackwardCompatibleProperty( + $this->content, + 'imageHelper', + $this->imageHelper + ); + + $this->objectManager->setBackwardCompatibleProperty( + $this->content, + 'assetRepo', + $this->assetRepo + ); + + $placeholderUrl = 'url_to_the_placeholder/placeholder.jpg'; + + $sizePlaceholder = ['size' => 399659]; + + $imagesResult = [ + [ + 'value_id' => '2', + 'file' => 'file_2.jpg', + 'media_type' => 'image', + 'position' => '0', + 'url' => 'url_to_the_placeholder/placeholder.jpg', + 'size' => 399659 + ], + [ + 'value_id' => '1', + 'file' => 'file_1.jpg', + 'media_type' => 'image', + 'position' => '1', + 'url' => 'url_to_the_placeholder/placeholder.jpg', + 'size' => 399659 + ] + ]; + + $images = [ + 'images' => [ + [ + 'value_id' => '1', + 'file' => 'file_1.jpg', + 'media_type' => 'image', + 'position' => '1' + ], + [ + 'value_id' => '2', + 'file' => 'file_2.jpg', + 'media_type' => 'image', + 'position' => '0' + ] + ] + ]; + + $this->content->setElement($this->galleryMock); + $this->galleryMock->expects($this->once())->method('getImages')->willReturn($images); + $this->fileSystemMock->expects($this->any())->method('getDirectoryRead')->willReturn($this->readMock); + $this->mediaConfigMock->expects($this->any())->method('getMediaUrl'); + $this->mediaConfigMock->expects($this->any())->method('getMediaPath'); + $this->readMock->expects($this->any())->method('stat')->willReturnOnConsecutiveCalls( + $this->throwException( + new \Magento\Framework\Exception\FileSystemException(new \Magento\Framework\Phrase('test')) + ), + $sizePlaceholder, + $this->throwException( + new \Magento\Framework\Exception\FileSystemException(new \Magento\Framework\Phrase('test')) + ), + $sizePlaceholder + ); + $this->imageHelper->expects($this->any())->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl); + $this->imageHelper->expects($this->any())->method('getPlaceholder'); + $this->assetRepo->expects($this->any())->method('createAsset')->willReturnSelf(); + $this->assetRepo->expects($this->any())->method('getPath'); + $this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode'); + + $this->assertSame(json_encode($imagesResult), $this->content->getImagesJson()); + } } diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php index 859f510024b8194b9b6c4b516f2084313eafc490..c5e90e27658ff8b8625394987c1954b775537437 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -84,6 +84,22 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase $cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class) ->getMockForAbstractClass(); + $storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + ->setMethods(['getStore', 'getCode']) + ->getMockForAbstractClass(); + $storeManager->expects($this->any())->method('getStore')->willReturnSelf(); + + $appState = $this->getMockBuilder('\Magento\Framework\App\State') + ->disableOriginalConstructor() + ->getMock(); + + $resolver = $this->getMockBuilder('\Magento\Framework\View\Element\Template\File\Resolver') + ->disableOriginalConstructor() + ->getMock(); + + $urlBuilder = $this->getMockBuilder('\Magento\Framework\UrlInterface') + ->getMockForAbstractClass(); + $scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); $context->expects($this->any()) @@ -104,6 +120,18 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase $context->expects($this->any()) ->method('getCacheState') ->will($this->returnValue($cacheState)); + $context->expects($this->any()) + ->method('getStoreManager') + ->will($this->returnValue($storeManager)); + $context->expects($this->any()) + ->method('getAppState') + ->will($this->returnValue($appState)); + $context->expects($this->any()) + ->method('getResolver') + ->will($this->returnValue($resolver)); + $context->expects($this->any()) + ->method('getUrlBuilder') + ->will($this->returnValue($urlBuilder)); $this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool') ->disableOriginalConstructor() @@ -338,4 +366,9 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase $this->assertEmpty($this->object->toHtml()); } + + public function testGetCacheKeyInfo() + { + $this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo()); + } } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php index a618ca4703370c4961e8e90727b084d13bd8418f..3b92e54355fb66be4eb76cec2651ffbbab88434b 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php @@ -412,7 +412,7 @@ class AdvancedPricing extends AbstractModifier 'data' => [ 'config' => [ 'componentType' => 'dynamicRows', - 'label' => __('Tier Price'), + 'label' => __('Customer Group Price'), 'renderDefaultRecord' => false, 'recordTemplate' => 'record', 'dataScope' => '', diff --git a/app/code/Magento/Catalog/i18n/en_US.csv b/app/code/Magento/Catalog/i18n/en_US.csv index 0745c98d7169aa535df248e697d0cba8c549ba8b..946eb60e616e18d8a8b5d5922868edc49eb8f5e3 100644 --- a/app/code/Magento/Catalog/i18n/en_US.csv +++ b/app/code/Magento/Catalog/i18n/en_US.csv @@ -405,6 +405,7 @@ Images,Images Select...,Select... "Advanced Pricing","Advanced Pricing" "Tier Price","Tier Price" +"Customer Group Price","Customer Group Price" "Customer Group","Customer Group" "Special Price From","Special Price From" To,To diff --git a/app/code/Magento/PageCache/etc/varnish3.vcl b/app/code/Magento/PageCache/etc/varnish3.vcl index feb4d7c14df56a9ffce64d58c5b259c359e609b1..555661f81b78aed87b4fbd79756c555eadc8b2f8 100644 --- a/app/code/Magento/PageCache/etc/varnish3.vcl +++ b/app/code/Magento/PageCache/etc/varnish3.vcl @@ -6,6 +6,7 @@ import std; backend default { .host = "/* {{ host }} */"; .port = "/* {{ port }} */"; + .first_byte_timeout = 600s; } acl purge { diff --git a/app/code/Magento/PageCache/etc/varnish4.vcl b/app/code/Magento/PageCache/etc/varnish4.vcl index dafeefbe5b5b7209626d23a97d1fbe88587e7450..559730af2d814b38b911a4f150bd8e04a7cbbc45 100644 --- a/app/code/Magento/PageCache/etc/varnish4.vcl +++ b/app/code/Magento/PageCache/etc/varnish4.vcl @@ -7,6 +7,7 @@ import std; backend default { .host = "/* {{ host }} */"; .port = "/* {{ port }} */"; + .first_byte_timeout = 600s; } acl purge { diff --git a/nginx.conf.sample b/nginx.conf.sample index 95f03f4dd2145f6f5521f1cb5eb770645e0c9f40..bb872a609e6446aea46b0a96427e880e1e2b4714 100644 --- a/nginx.conf.sample +++ b/nginx.conf.sample @@ -38,6 +38,12 @@ location ~* ^/setup($|/) { root $MAGE_ROOT; location ~ ^/setup/index.php { fastcgi_pass fastcgi_backend; + + fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; + fastcgi_param PHP_VALUE "memory_limit=768M \n max_execution_time=600"; + fastcgi_read_timeout 600s; + fastcgi_connect_timeout 600s; + fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;