diff --git a/app/code/Magento/Checkout/CustomerData/DefaultItem.php b/app/code/Magento/Checkout/CustomerData/DefaultItem.php index 6e917366c9cd2..9351685405a60 100644 --- a/app/code/Magento/Checkout/CustomerData/DefaultItem.php +++ b/app/code/Magento/Checkout/CustomerData/DefaultItem.php @@ -6,6 +6,8 @@ namespace Magento\Checkout\CustomerData; +use Magento\Framework\App\ObjectManager; + /** * Default item */ @@ -36,12 +38,20 @@ class DefaultItem extends AbstractItem */ protected $checkoutHelper; + /** + * Escaper + * + * @var \Magento\Framework\Escaper + */ + private $escaper; + /** * @param \Magento\Catalog\Helper\Image $imageHelper * @param \Magento\Msrp\Helper\Data $msrpHelper * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool * @param \Magento\Checkout\Helper\Data $checkoutHelper + * @param \Magento\Framework\Escaper|null $escaper * @codeCoverageIgnore */ public function __construct( @@ -49,13 +59,15 @@ public function __construct( \Magento\Msrp\Helper\Data $msrpHelper, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool, - \Magento\Checkout\Helper\Data $checkoutHelper + \Magento\Checkout\Helper\Data $checkoutHelper, + \Magento\Framework\Escaper $escaper = null ) { $this->configurationPool = $configurationPool; $this->imageHelper = $imageHelper; $this->msrpHelper = $msrpHelper; $this->urlBuilder = $urlBuilder; $this->checkoutHelper = $checkoutHelper; + $this->escaper = $escaper ?: ObjectManager::getInstance()->get(\Magento\Framework\Escaper::class); } /** @@ -64,6 +76,8 @@ public function __construct( protected function doGetItemData() { $imageHelper = $this->imageHelper->init($this->getProductForThumbnail(), 'mini_cart_product_thumbnail'); + $productName = $this->escaper->escapeHtml($this->item->getProduct()->getName()); + return [ 'options' => $this->getOptionList(), 'qty' => $this->item->getQty() * 1, @@ -71,7 +85,7 @@ protected function doGetItemData() 'configure_url' => $this->getConfigureUrl(), 'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(), 'product_id' => $this->item->getProduct()->getId(), - 'product_name' => $this->item->getProduct()->getName(), + 'product_name' => $productName, 'product_sku' => $this->item->getProduct()->getSku(), 'product_url' => $this->getProductUrl(), 'product_has_url' => $this->hasProductUrl(), diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml index 3316e0f46ff8f..420e674083b1c 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml @@ -25,7 +25,7 @@ getIsNeedToDisplaySideBar()): ?> -
willReturn($this->rating); $this->messageManager = $this->getMock('\Magento\Framework\Message\ManagerInterface'); - $this->store = $this->getMock('\Magento\Store\Model\Store', ['getId'], [], '', false); + $this->store = $this->getMock( + '\Magento\Store\Model\Store', + ['getId', 'getWebsiteId'], + [], + '', + false + ); $storeManager = $this->getMockForAbstractClass('\Magento\Store\Model\StoreManagerInterface'); $storeManager->expects($this->any())->method('getStore')->willReturn($this->store); @@ -242,7 +248,7 @@ public function testExecute() ->willReturn(1); $product = $this->getMock( 'Magento\Catalog\Model\Product', - ['__wakeup', 'isVisibleInCatalog', 'isVisibleInSiteVisibility', 'getId'], + ['__wakeup', 'isVisibleInCatalog', 'isVisibleInSiteVisibility', 'getId', 'getWebsiteIds'], [], '', false @@ -253,6 +259,10 @@ public function testExecute() $product->expects($this->once()) ->method('isVisibleInSiteVisibility') ->willReturn(true); + $product->expects($this->once()) + ->method('getWebsiteIds') + ->willReturn([1]); + $this->productRepository->expects($this->any())->method('getById') ->with(1) ->willReturn($product); @@ -288,6 +298,8 @@ public function testExecute() $this->review->expects($this->once())->method('setCustomerId')->with($customerId)->willReturnSelf(); $this->store->expects($this->exactly(2))->method('getId') ->willReturn($storeId); + $this->store->expects($this->once())->method('getWebsiteId') + ->willReturn(1); $this->review->expects($this->once())->method('setStoreId') ->with($storeId) ->willReturnSelf(); diff --git a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php index b5477c6de8d4d..6e836bae1e215 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php @@ -851,7 +851,7 @@ protected function _drawItem(\Magento\Framework\DataObject $item, \Zend_Pdf_Page protected function _setFontRegular($object, $size = 7) { $font = \Zend_Pdf_Font::fontWithPath( - $this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Re-4.4.1.ttf') + $this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerif.ttf') ); $object->setFont($font, $size); return $font; @@ -867,7 +867,7 @@ protected function _setFontRegular($object, $size = 7) protected function _setFontBold($object, $size = 7) { $font = \Zend_Pdf_Font::fontWithPath( - $this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf') + $this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifBold.ttf') ); $object->setFont($font, $size); return $font; @@ -883,7 +883,7 @@ protected function _setFontBold($object, $size = 7) protected function _setFontItalic($object, $size = 7) { $font = \Zend_Pdf_Font::fontWithPath( - $this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_It-2.8.2.ttf') + $this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifItalic.ttf') ); $object->setFont($font, $size); return $font; diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php index ce63d77f1d5d7..15d1a83dfd313 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php @@ -335,7 +335,7 @@ public function getItemOptions() protected function _setFontRegular($size = 7) { $font = \Zend_Pdf_Font::fontWithPath( - $this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Re-4.4.1.ttf') + $this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerif.ttf') ); $this->getPage()->setFont($font, $size); return $font; @@ -350,7 +350,7 @@ protected function _setFontRegular($size = 7) protected function _setFontBold($size = 7) { $font = \Zend_Pdf_Font::fontWithPath( - $this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_Bd-2.8.1.ttf') + $this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifBold.ttf') ); $this->getPage()->setFont($font, $size); return $font; @@ -365,7 +365,7 @@ protected function _setFontBold($size = 7) protected function _setFontItalic($size = 7) { $font = \Zend_Pdf_Font::fontWithPath( - $this->_rootDirectory->getAbsolutePath('lib/internal/LinLibertineFont/LinLibertine_It-2.8.2.ttf') + $this->_rootDirectory->getAbsolutePath('lib/internal/GnuFreeFont/FreeSerifItalic.ttf') ); $this->getPage()->setFont($font, $size); return $font; diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less index 019627bc01fc5..9d13249a5b86d 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less @@ -238,7 +238,6 @@ .product-item-pricing { .label { display: inline-block; - width: 4.5rem; } } diff --git a/app/design/frontend/Magento/blank/web/css/source/_extends.less b/app/design/frontend/Magento/blank/web/css/source/_extends.less index 19c76d2feb454..58adadf8f1a82 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_extends.less +++ b/app/design/frontend/Magento/blank/web/css/source/_extends.less @@ -1232,7 +1232,7 @@ } } -.media-width(@extremum, @break) when (@extremum = 'max') and (@break = (@screen__m + 1)) { +.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { .abs-checkout-tooltip-content-position-top-mobile { @abs-checkout-tooltip-content-position-top(); } diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less index e8a4b5af1168d..3f26e87c34be2 100644 --- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less +++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less @@ -243,7 +243,6 @@ .product-item-pricing { .label { display: inline-block; - width: 4.5rem; } } diff --git a/app/design/frontend/Magento/luma/web/css/source/_extends.less b/app/design/frontend/Magento/luma/web/css/source/_extends.less index c2a3e7dbd8392..20fa098ba2c4a 100644 --- a/app/design/frontend/Magento/luma/web/css/source/_extends.less +++ b/app/design/frontend/Magento/luma/web/css/source/_extends.less @@ -1673,7 +1673,7 @@ } } -.media-width(@extremum, @break) when (@extremum = 'max') and (@break = (@screen__m + 1)) { +.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { .abs-checkout-tooltip-content-position-top-mobile { @abs-checkout-tooltip-content-position-top(); } diff --git a/lib/internal/GnuFreeFont/FreeSerif.ttf b/lib/internal/GnuFreeFont/FreeSerif.ttf new file mode 100644 index 0000000000000..889c594f6674e Binary files /dev/null and b/lib/internal/GnuFreeFont/FreeSerif.ttf differ diff --git a/lib/internal/GnuFreeFont/FreeSerifBold.ttf b/lib/internal/GnuFreeFont/FreeSerifBold.ttf new file mode 100644 index 0000000000000..49112d3a92c96 Binary files /dev/null and b/lib/internal/GnuFreeFont/FreeSerifBold.ttf differ diff --git a/lib/internal/GnuFreeFont/FreeSerifItalic.ttf b/lib/internal/GnuFreeFont/FreeSerifItalic.ttf new file mode 100644 index 0000000000000..4ea68896dc3d3 Binary files /dev/null and b/lib/internal/GnuFreeFont/FreeSerifItalic.ttf differ diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php index a0327ebe1202c..288657cd6c613 100644 --- a/lib/internal/Magento/Framework/Console/Cli.php +++ b/lib/internal/Magento/Framework/Console/Cli.php @@ -17,6 +17,7 @@ use Magento\Framework\Shell\ComplexParameter; use Magento\Setup\Console\CompilerPreparation; use \Magento\Framework\App\ProductMetadata; +use Magento\Framework\App\State; /** * Magento 2 CLI Application. This is the hood for all command line tools supported by Magento @@ -47,6 +48,11 @@ class Cli extends SymfonyApplication */ private $initException; + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + /** * @param string $name application name * @param string $version application version @@ -56,15 +62,7 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') { $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php') ->getServiceManager(); - $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager); - if (!$generationDirectoryAccess->check()) { - $output = new ConsoleOutput(); - $output->writeln( - 'Command line user does not have read and write permissions on var/generation directory. Please' - . ' address this issue before using Magento command line.' - ); - exit(0); - } + /** * Temporary workaround until the compiler is able to clear the generation directory * @todo remove after MAGETWO-44493 resolved @@ -74,6 +72,21 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') $compilerPreparation->handleCompilerEnvironment(); } + $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP); + $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER); + $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null; + $bootstrap = Bootstrap::create(BP, $params); + $this->objectManager = $bootstrap->getObjectManager(); + + if ($this->checkGenerationDirectoryAccess()) { + $output = new ConsoleOutput(); + $output->writeln( + 'Command line user does not have read and write permissions on var/generation directory. Please' + . ' address this issue before using Magento command line.' + ); + exit(0); + } + if ($version == 'UNKNOWN') { $directoryList = new DirectoryList(BP); $composerJsonFinder = new ComposerJsonFinder($directoryList); @@ -83,6 +96,22 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') parent::__construct($name, $version); } + /** + * Check generation directory access. + * + * Skip and return true if production mode is enabled. + * + * @return bool + */ + private function checkGenerationDirectoryAccess() + { + $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager); + /** @var State $state */ + $state = $this->objectManager->create(State::class); + + return $state->getMode() !== State::MODE_PRODUCTION && !$generationDirectoryAccess->check(); + } + /** * Process an error happened during initialization of commands, if any * @@ -121,31 +150,25 @@ protected function getApplicationCommands() { $commands = []; try { - $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP); - $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER); - $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null; - $bootstrap = Bootstrap::create(BP, $params); - $objectManager = $bootstrap->getObjectManager(); - // Specialized setup command list available before and after M2 install if (class_exists('Magento\Setup\Console\CommandList') && class_exists('Magento\Setup\Model\ObjectManagerProvider') ) { /** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */ $omProvider = $this->serviceManager->get(\Magento\Setup\Model\ObjectManagerProvider::class); - $omProvider->setObjectManager($objectManager); + $omProvider->setObjectManager($this->objectManager); $setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager); $commands = array_merge($commands, $setupCommandList->getCommands()); } // Allowing instances of all modular commands only after M2 install - if ($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) { + if ($this->objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) { /** @var \Magento\Framework\Console\CommandListInterface $commandList */ - $commandList = $objectManager->create(\Magento\Framework\Console\CommandListInterface::class); + $commandList = $this->objectManager->create(\Magento\Framework\Console\CommandListInterface::class); $commands = array_merge($commands, $commandList->getCommands()); } - $commands = array_merge($commands, $this->getVendorCommands($objectManager)); + $commands = array_merge($commands, $this->getVendorCommands($this->objectManager)); } catch (\Exception $e) { $this->initException = $e; } diff --git a/lib/internal/Magento/Framework/Mview/View/Changelog.php b/lib/internal/Magento/Framework/Mview/View/Changelog.php index 91caf66228360..17b4436ad6cb7 100644 --- a/lib/internal/Magento/Framework/Mview/View/Changelog.php +++ b/lib/internal/Magento/Framework/Mview/View/Changelog.php @@ -121,7 +121,7 @@ public function clear($versionId) throw new ChangelogTableNotExistsException(new Phrase("Table %1 does not exist", [$changelogTableName])); } - $this->connection->delete($changelogTableName, ['version_id <= ?' => (int)$versionId]); + $this->connection->delete($changelogTableName, ['version_id < ?' => (int)$versionId]); return true; } diff --git a/lib/internal/Magento/Framework/Setup/FilePermissions.php b/lib/internal/Magento/Framework/Setup/FilePermissions.php index 4cf5f1897da9d..e77d55985f209 100644 --- a/lib/internal/Magento/Framework/Setup/FilePermissions.php +++ b/lib/internal/Magento/Framework/Setup/FilePermissions.php @@ -9,6 +9,8 @@ use Magento\Framework\Backup\Filesystem\Iterator\Filter; use Magento\Framework\Filesystem\Filter\ExcludeFilter; use Magento\Framework\Filesystem; +use Magento\Framework\App\State; +use Magento\Framework\App\ObjectManager; class FilePermissions { @@ -22,6 +24,11 @@ class FilePermissions */ protected $directoryList; + /** + * @var State + */ + private $state; + /** * List of required writable directories for installation * @@ -60,13 +67,16 @@ class FilePermissions /** * @param Filesystem $filesystem * @param DirectoryList $directoryList + * @param State $state */ public function __construct( Filesystem $filesystem, - DirectoryList $directoryList + DirectoryList $directoryList, + State $state = null ) { $this->filesystem = $filesystem; $this->directoryList = $directoryList; + $this->state = $state ?: ObjectManager::getInstance()->get(State::class); } /** @@ -141,12 +151,15 @@ private function checkRecursiveDirectories($directory) new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST ); - $noWritableFilesFolders = [ - $this->directoryList->getPath(DirectoryList::GENERATION) . '/', - $this->directoryList->getPath(DirectoryList::DI) . '/', - ]; - $directoryIterator = new Filter($directoryIterator, $noWritableFilesFolders); + $generationPath = $this->directoryList->getPath(DirectoryList::GENERATION); + $diPath = $this->directoryList->getPath(DirectoryList::DI); + + if ($this->state->getMode() === State::MODE_PRODUCTION) { + $directoryIterator = new ExcludeFilter($directoryIterator, [$generationPath, $diPath]); + } else { + $directoryIterator = new Filter($directoryIterator, [$generationPath . '/', $diPath . '/']); + } $directoryIterator = new ExcludeFilter( $directoryIterator, diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php index d01ba26b04a73..4fea4ebfdbb91 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php @@ -7,6 +7,7 @@ use \Magento\Framework\Setup\FilePermissions; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\State; class FilePermissionsTest extends \PHPUnit_Framework_TestCase { @@ -25,6 +26,11 @@ class FilePermissionsTest extends \PHPUnit_Framework_TestCase */ private $directoryListMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|State + */ + private $stateMock; + /** * @var FilePermissions */ @@ -34,6 +40,7 @@ public function setUp() { $this->directoryWriteMock = $this->getMock('Magento\Framework\Filesystem\Directory\Write', [], [], '', false); $this->filesystemMock = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->stateMock = $this->getMock(State::class, [], [], '', false); $this->filesystemMock ->expects($this->any()) @@ -43,7 +50,8 @@ public function setUp() $this->filePermissions = new FilePermissions( $this->filesystemMock, - $this->directoryListMock + $this->directoryListMock, + $this->stateMock ); } @@ -219,6 +227,7 @@ public function setUpDirectoryListInstallation() ->method('getPath') ->with(DirectoryList::STATIC_VIEW) ->will($this->returnValue(BP . '/pub/static')); + } public function setUpDirectoryWriteInstallation() diff --git a/setup/index.php b/setup/index.php index cf74b2319c6c5..33ab0aa39809a 100644 --- a/setup/index.php +++ b/setup/index.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +use Zend\Mvc\Application; +use Magento\Setup\Model\ObjectManagerProvider; if (PHP_SAPI == 'cli') { echo "You cannot run this from the command line." . PHP_EOL . @@ -28,4 +30,8 @@ $handler = new \Magento\Framework\App\ErrorHandler(); set_error_handler([$handler, 'handler']); -\Zend\Mvc\Application::init(require __DIR__ . '/config/application.config.php')->run(); +$application = Application::init(require __DIR__ . '/config/application.config.php'); +$application->getServiceManager() + ->get(ObjectManagerProvider::class) + ->setObjectManager(\Magento\Framework\App\Bootstrap::create(BP, $_SERVER)->getObjectManager()); +$application->run(); diff --git a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php index 42e49d6fc703f..fa580e57a76cd 100644 --- a/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php +++ b/setup/src/Magento/Setup/Mvc/Bootstrap/InitParamListener.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Setup\Mvc\Bootstrap; use Magento\Framework\App\Bootstrap as AppBootstrap; @@ -137,8 +136,7 @@ public function authPreDispatch($event) /** @var \Magento\Backend\Model\Auth $auth */ $authentication = $objectManager->get(\Magento\Backend\Model\Auth::class); - if ( - !$authentication->isLoggedIn() || + if (!$authentication->isLoggedIn() || !$adminSession->isAllowed('Magento_Backend::setup_wizard') ) { $adminSession->destroy();