diff --git a/app/bootstrap.php b/app/bootstrap.php index f51265aee618e..23ab8e404587a 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -31,8 +31,15 @@ require_once __DIR__ . '/autoload.php'; require_once BP . '/app/functions.php'; -if (!empty($_SERVER['MAGE_PROFILER'])) { - \Magento\Framework\Profiler::applyConfig($_SERVER['MAGE_PROFILER'], BP, !empty($_REQUEST['isAjax'])); +if (!empty($_SERVER['MAGE_PROFILER']) + && isset($_SERVER['HTTP_ACCEPT']) + && strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false +) { + \Magento\Framework\Profiler::applyConfig( + $_SERVER['MAGE_PROFILER'], + BP, + !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' + ); } if (ini_get('date.timezone') == '') { date_default_timezone_set('UTC'); diff --git a/app/code/Magento/Catalog/etc/product_options_merged.xsd b/app/code/Magento/Catalog/etc/product_options_merged.xsd index 68268f1d9cd1f..5cf7fcf2fce99 100644 --- a/app/code/Magento/Catalog/etc/product_options_merged.xsd +++ b/app/code/Magento/Catalog/etc/product_options_merged.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/Catalog/etc/product_types.xsd b/app/code/Magento/Catalog/etc/product_types.xsd index 8dc3de773c169..a607244d5e976 100644 --- a/app/code/Magento/Catalog/etc/product_types.xsd +++ b/app/code/Magento/Catalog/etc/product_types.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/Catalog/etc/product_types_merged.xsd b/app/code/Magento/Catalog/etc/product_types_merged.xsd index 3595808492434..3098817cea101 100644 --- a/app/code/Magento/Catalog/etc/product_types_merged.xsd +++ b/app/code/Magento/Catalog/etc/product_types_merged.xsd @@ -7,7 +7,7 @@ --> - + diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml index e1bdb4dbcb9be..4e021bbafe02b 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ product_listing.product_listing_data_source diff --git a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml index a4f0f8c41ec97..944e05f55a651 100644 --- a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml +++ b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml index 6775549e39d49..d986cbfef3be1 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_block_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ cms_block_listing.cms_block_listing_data_source diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml index 27cc3ddc2e019..551a0709d2ea7 100644 --- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml +++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ cms_page_listing.cms_page_listing_data_source diff --git a/app/code/Magento/Config/Observer/Config/Backend/Admin/AfterCustomUrlChangedObserver.php b/app/code/Magento/Config/Observer/Config/Backend/Admin/AfterCustomUrlChangedObserver.php index 36c952ae45722..816984b860b5a 100644 --- a/app/code/Magento/Config/Observer/Config/Backend/Admin/AfterCustomUrlChangedObserver.php +++ b/app/code/Magento/Config/Observer/Config/Backend/Admin/AfterCustomUrlChangedObserver.php @@ -33,38 +33,31 @@ class AfterCustomUrlChangedObserver implements ObserverInterface */ protected $_response; - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_storeManager; - /** * @param \Magento\Backend\Helper\Data $backendData * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Backend\Model\Auth\Session $authSession * @param \Magento\Framework\App\ResponseInterface $response - * @param \Magento\Store\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\Helper\Data $backendData, \Magento\Framework\Registry $coreRegistry, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Framework\App\ResponseInterface $response, - \Magento\Store\Model\StoreManagerInterface $storeManager + \Magento\Framework\App\ResponseInterface $response ) { $this->_backendData = $backendData; $this->_coreRegistry = $coreRegistry; $this->_authSession = $authSession; $this->_response = $response; - $this->_storeManager = $storeManager; } /** - * Log out user and redirect him to new admin custom url + * Log out user and redirect to new admin custom url * * @param \Magento\Framework\Event\Observer $observer * @return void * @SuppressWarnings(PHPMD.ExitExpression) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute(\Magento\Framework\Event\Observer $observer) { @@ -73,10 +66,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) } $this->_authSession->destroy(); - - $route = $this->_backendData->getAreaFrontName(); - - $this->_response->setRedirect($this->_storeManager->getStore()->getBaseUrl() . $route)->sendResponse(); + $adminUrl = $this->_backendData->getHomePageUrl(); + $this->_response->setRedirect($adminUrl)->sendResponse(); exit(0); } } diff --git a/app/code/Magento/Config/etc/system_include.xsd b/app/code/Magento/Config/etc/system_include.xsd index 2c39b82927d2b..4b36237a673ce 100644 --- a/app/code/Magento/Config/etc/system_include.xsd +++ b/app/code/Magento/Config/etc/system_include.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index 7fd14ff394f9b..19aa14654252d 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ configurable_associated_product_listing.data_source diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml index edf1f8cae1c9e..befdbacd70599 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ product_attributes_listing.product_attributes_listing_data_source diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml index 5c01b2cb6c7b8..e1a9e9aa7ec2f 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ customer_listing.customer_listing_data_source diff --git a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml index c864f2ac240f4..7a1e66f70ba89 100644 --- a/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml +++ b/app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ customer_online_grid.customer_online_grid_data_source diff --git a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml index 0fa2ab59bcc75..d03507aba2780 100644 --- a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml +++ b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -
+ customer_form.customer_form_data_source diff --git a/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php b/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php new file mode 100644 index 0000000000000..689d408926d0c --- /dev/null +++ b/app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php @@ -0,0 +1,178 @@ +filesUtility = $filesUtility; + $this->urnResolver = $urnResolver; + $this->formats = $formats; + $this->rootDirRead = $filesystemFactory->getDirectoryRead(DirectoryList::ROOT); + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->setName('dev:urn-catalog:generate') + ->setDescription('Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml.') + ->setDefinition([ + new InputOption( + self::IDE_OPTION, + null, + InputOption::VALUE_REQUIRED, + 'Format in which catalog will be generated. Supported: ['. + implode(', ', $this->getSupportedFormats()) . ']', + 'phpstorm' + ), + new InputArgument( + self::IDE_FILE_PATH_ARGUMENT, + InputArgument::REQUIRED, + 'Path to file to output the catalog. For PhpStorm use .idea/misc.xml' + ) + ]); + + parent::configure(); + } + + /** + * Get an array of URNs + * + * @param OutputInterface $output + * @return array + */ + private function getUrnDictionary(OutputInterface $output) + { + $files = $this->filesUtility->getXmlCatalogFiles('*.xml'); + $files = array_merge($files, $this->filesUtility->getXmlCatalogFiles('*.xsd')); + + $urns = []; + foreach ($files as $file) { + $content = $this->rootDirRead->readFile( + $this->rootDirRead->getRelativePath($file[0]) + ); + $matches = []; + preg_match_all('/schemaLocation="(urn\:magento\:[^"]*)"/i', $content, $matches); + if (isset($matches[1])) { + $urns = array_merge($urns, $matches[1]); + } + } + $urns = array_unique($urns); + $paths = []; + foreach ($urns as $urn) { + try { + $paths[$urn] = $this->urnResolver->getRealPath($urn); + } catch (\Exception $e) { + // don't add unsupported element to array + if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { + $output->writeln($e->getMessage()); + } + } + } + return $paths; + } + + /** + * {@inheritdoc} + * @throws \InvalidArgumentException + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $ideName = $input->getOption(self::IDE_OPTION); + $ideFilePath = $input->getArgument(self::IDE_FILE_PATH_ARGUMENT); + + $urnDictionary = $this->getUrnDictionary($output); + if ($formatter = $this->getFormatters($ideName)) { + $formatter->generateCatalog($urnDictionary, $ideFilePath); + } else { + throw new InputException(__("Format for IDE '%1' is not supported", $ideName)); + } + } + + /** + * Get formatter based on format + * + * @param string $format + * @return \Magento\Developer\Model\XmlCatalog\Format\FormatInterface|false + */ + private function getFormatters($format) + { + if (!isset($this->formats[$format])) { + return false; + } + return $this->formats[$format]; + } + + /** + * Get registered formatter aliases + * + * @return string[] + */ + public function getSupportedFormats() + { + return array_keys($this->formats); + } +} diff --git a/app/code/Magento/Developer/Model/XmlCatalog/Format/FormatInterface.php b/app/code/Magento/Developer/Model/XmlCatalog/Format/FormatInterface.php new file mode 100644 index 0000000000000..5a43380cb3a1c --- /dev/null +++ b/app/code/Magento/Developer/Model/XmlCatalog/Format/FormatInterface.php @@ -0,0 +1,22 @@ +currentDirRead = $readFactory->create(getcwd()); + $this->fileWriteFactory = $fileWriteFactory; + } + + /** + * Generate Catalog of URNs for the PhpStorm 9 + * + * @param string[] $dictionary + * @param string $configFilePath relative path to the PhpStorm misc.xml + * @return void + */ + public function generateCatalog(array $dictionary, $configFilePath) + { + $componentNode = null; + $projectNode = null; + + try { + $file = $this->fileWriteFactory->create( + $configFilePath, + \Magento\Framework\Filesystem\DriverPool::FILE, + 'r' + ); + $dom = new \DOMDocument(); + $dom->loadXML($file->readAll()); + $xpath = new \DOMXPath($dom); + $nodeList = $xpath->query('/project'); + $projectNode = $nodeList->item(0); + $file->close(); + } catch (FileSystemException $f) { + //create file if does not exists + $dom = new \DOMDocument(); + $projectNode = $dom->createElement('project'); + + //PhpStorm 9 version for component is "4" + $projectNode->setAttribute('version', '4'); + $dom->appendChild($projectNode); + $rootComponentNode = $dom->createElement('component'); + + //PhpStorm 9 version for ProjectRootManager is "2" + $rootComponentNode->setAttribute('version', '2'); + $rootComponentNode->setAttribute('name', 'ProjectRootManager'); + $projectNode->appendChild($rootComponentNode); + } + + $xpath = new \DOMXPath($dom); + $nodeList = $xpath->query("/project/component[@name='ProjectResources']"); + $componentNode = $nodeList->item(0); + if ($componentNode == null) { + $componentNode = $dom->createElement('component'); + $componentNode->setAttribute('name', 'ProjectResources'); + $projectNode->appendChild($componentNode); + } + + foreach ($dictionary as $urn => $xsdPath) { + $node = $dom->createElement('resource'); + $node->setAttribute('url', $urn); + $node->setAttribute('location', $xsdPath); + $componentNode->appendChild($node); + } + $dom->formatOutput = true; + $file = $this->fileWriteFactory->create( + $configFilePath, + \Magento\Framework\Filesystem\DriverPool::FILE, + 'w' + ); + $file->write($dom->saveXML()); + $file->close(); + } +} diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php new file mode 100644 index 0000000000000..c894b93af9050 --- /dev/null +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php @@ -0,0 +1,73 @@ +getMock('\Magento\Framework\App\Utility\Files', ['getXmlCatalogFiles'], [], '', false); + $filesMock->expects($this->at(0)) + ->method('getXmlCatalogFiles') + ->will($this->returnValue([[$fixtureXmlFile]])); + $filesMock->expects($this->at(1)) + ->method('getXmlCatalogFiles') + ->will($this->returnValue([])); + $urnResolverMock = $this->getMock('\Magento\Framework\Config\Dom\UrnResolver', [], [], '', false); + $urnResolverMock->expects($this->once()) + ->method('getRealPath') + ->with($this->equalTo('urn:magento:framework:Module/etc/module.xsd')) + ->will($this->returnValue($fixtureXmlFile)); + + $phpstormFormatMock = $this->getMock('\Magento\Developer\Model\XmlCatalog\Format\PhpStorm', [], [], '', false); + $phpstormFormatMock->expects($this->once()) + ->method('generateCatalog') + ->with( + $this->equalTo(['urn:magento:framework:Module/etc/module.xsd' => $fixtureXmlFile]), + $this->equalTo('test') + )->will($this->returnValue(null)); + + $formats = ['phpstorm' => $phpstormFormatMock]; + $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $readDirMock = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface', [], [], '', false); + + $content = file_get_contents($fixtureXmlFile); + + $readDirMock->expects($this->once()) + ->method('getRelativePath') + ->with($this->equalTo($fixtureXmlFile)) + ->will($this->returnValue('test')); + $readDirMock->expects($this->once()) + ->method('readFile') + ->with($this->equalTo('test')) + ->will($this->returnValue($content)); + $filesystem->expects($this->once()) + ->method('getDirectoryRead') + ->will($this->returnValue($readDirMock)); + + $this->command = new XmlCatalogGenerateCommand( + $filesMock, + $urnResolverMock, + $filesystem, + $formats + ); + + $commandTester = new CommandTester($this->command); + $commandTester->execute([XmlCatalogGenerateCommand::IDE_FILE_PATH_ARGUMENT => 'test']); + $this->assertEquals('', $commandTester->getDisplay()); + } +} diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/_files/test.xml b/app/code/Magento/Developer/Test/Unit/Console/Command/_files/test.xml new file mode 100644 index 0000000000000..f98f1581079dd --- /dev/null +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/_files/test.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml index a393b0ebce8bc..2565d9ad705f6 100644 --- a/app/code/Magento/Developer/etc/di.xml +++ b/app/code/Magento/Developer/etc/di.xml @@ -15,6 +15,13 @@ Magento\Developer\Model\View\Page\Config\RendererFactory + + + + Magento\Developer\Model\XmlCatalog\Format\PhpStorm + + + @@ -88,6 +95,7 @@ Magento\Developer\Console\Command\DevTestsRunCommand Magento\Developer\Console\Command\SourceThemeDeployCommand Magento\Developer\Console\Command\XmlConverterCommand + Magento\Developer\Console\Command\XmlCatalogGenerateCommand diff --git a/app/code/Magento/ImportExport/etc/export_merged.xsd b/app/code/Magento/ImportExport/etc/export_merged.xsd index 6a886e405f7a8..e14fab413e479 100644 --- a/app/code/Magento/ImportExport/etc/export_merged.xsd +++ b/app/code/Magento/ImportExport/etc/export_merged.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/ImportExport/etc/import_merged.xsd b/app/code/Magento/ImportExport/etc/import_merged.xsd index 208e3ba0ed78b..5b56b9468bf8e 100644 --- a/app/code/Magento/ImportExport/etc/import_merged.xsd +++ b/app/code/Magento/ImportExport/etc/import_merged.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml index 39cd52f20586c..59281daf4f0ff 100644 --- a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml +++ b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ diff --git a/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php b/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php index d86d8df059161..fd04f1fe4ca2f 100644 --- a/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php +++ b/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php @@ -76,11 +76,6 @@ public function aroundDispatch( $this->kernel->process($result); } } else { - json_decode($result->getContent()); - if (json_last_error() == JSON_ERROR_NONE) { - // reset profiler to avoid appending profiling stat to JSON response - \Magento\Framework\Profiler::reset(); - } $this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'HIT', true); } return $result; diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php index ae38b76db495f..9e4102c889052 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php @@ -200,7 +200,6 @@ public function testAroundDispatchReturnsCache($state) $this->responseMock->expects($this->never()) ->method('setHeader'); } - $this->responseMock->expects($this->once())->method('getContent'); $this->assertSame( $this->responseMock, $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock) diff --git a/app/code/Magento/Sales/etc/pdf_file.xsd b/app/code/Magento/Sales/etc/pdf_file.xsd index 42c5e2cb8112a..344d145a27215 100644 --- a/app/code/Magento/Sales/etc/pdf_file.xsd +++ b/app/code/Magento/Sales/etc/pdf_file.xsd @@ -8,7 +8,7 @@ */ --> - + diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml index a7f92654a75d0..d3dc8ff9de776 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ sales_order_creditmemo_grid.sales_order_creditmemo_grid_data_source diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml index 6e57da8d26084..c118bc2f9d76f 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ sales_order_grid.sales_order_grid_data_source diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml index 2022ef7f1d584..86e96448e5d2f 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_invoice_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ sales_order_invoice_grid.sales_order_invoice_grid_data_source diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml index 7fed192771788..76db34268b8ac 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_shipment_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ sales_order_shipment_grid.sales_order_shipment_grid_data_source diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml index 4377aefc1b19b..458516ec3ce0f 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ sales_order_view_creditmemo_grid.sales_order_view_creditmemo_grid_data_source diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml index 9ea839d31c23a..e421ca8ac4bcf 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ sales_order_view_invoice_grid.sales_order_view_invoice_grid_data_source diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml index 43539e5c20ccb..2afc583df2f08 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_shipment_grid.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -+ sales_order_view_shipment_grid.sales_order_view_shipment_grid_data_source diff --git a/app/code/Magento/Ui/etc/di.xml b/app/code/Magento/Ui/etc/di.xml index 1c59a83b3d54c..c021e1beddc02 100644 --- a/app/code/Magento/Ui/etc/di.xml +++ b/app/code/Magento/Ui/etc/di.xml @@ -78,7 +78,7 @@ - urn:magento:framework:Ui/etc/ui_configuration.xsd + urn:magento:module:Magento_Ui:etc/ui_configuration.xsd / @@ -111,7 +111,7 @@ - urn:magento:framework:Ui/etc/ui_definition.xsd + urn:magento:module:Magento_Ui:etc/ui_definition.xsd /components diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd b/app/code/Magento/Ui/etc/ui_components.xsd similarity index 99% rename from lib/internal/Magento/Framework/Ui/etc/ui_components.xsd rename to app/code/Magento/Ui/etc/ui_components.xsd index f57cee5918faf..dea805fd39bee 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd +++ b/app/code/Magento/Ui/etc/ui_components.xsd @@ -7,7 +7,7 @@ --> - + diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd b/app/code/Magento/Ui/etc/ui_configuration.xsd similarity index 98% rename from lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd rename to app/code/Magento/Ui/etc/ui_configuration.xsd index 9cdf105649446..2940882abe1da 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd +++ b/app/code/Magento/Ui/etc/ui_configuration.xsd @@ -11,7 +11,7 @@ The definition of a configuration item components - + diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd b/app/code/Magento/Ui/etc/ui_definition.xsd similarity index 97% rename from lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd rename to app/code/Magento/Ui/etc/ui_definition.xsd index 78cd48d5f43a2..e9f16f6f305ac 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd +++ b/app/code/Magento/Ui/etc/ui_definition.xsd @@ -7,7 +7,7 @@ --> - + diff --git a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml index 090c3a9e277a5..c722c6b817740 100755 --- a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml +++ b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> - + diff --git a/app/code/Magento/Widget/etc/widget.xsd b/app/code/Magento/Widget/etc/widget.xsd index 7ca6f649aed51..faf08d3afaf8e 100644 --- a/app/code/Magento/Widget/etc/widget.xsd +++ b/app/code/Magento/Widget/etc/widget.xsd @@ -6,7 +6,7 @@ */ --> - + Contains widgets. diff --git a/app/code/Magento/Widget/etc/widget_file.xsd b/app/code/Magento/Widget/etc/widget_file.xsd index f2f867bb4acf0..a587a3c2aae45 100644 --- a/app/code/Magento/Widget/etc/widget_file.xsd +++ b/app/code/Magento/Widget/etc/widget_file.xsd @@ -6,7 +6,7 @@ */ --> - + Contains widgets. diff --git a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php index de6160134035b..6a7827490ceb3 100644 --- a/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php +++ b/dev/tests/functional/lib/Magento/Mtf/App/State/AbstractState.php @@ -47,7 +47,10 @@ public function clearInstance() $configFilePool = \Magento\Mtf\ObjectManagerFactory::getObjectManager() ->get('\Magento\Framework\Config\File\ConfigFilePool'); - $reader = new Reader($dirList, $configFilePool); + $driverPool = \Magento\Mtf\ObjectManagerFactory::getObjectManager() + ->get('\Magento\Framework\Filesystem\DriverPool'); + + $reader = new Reader($dirList, $driverPool, $configFilePool); $deploymentConfig = new DeploymentConfig($reader); $host = $deploymentConfig->get( ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/' . ConfigOptionsListConstants::KEY_HOST diff --git a/dev/tests/integration/etc/install-config-mysql.travis.php.dist b/dev/tests/integration/etc/install-config-mysql.travis.php.dist index ac8eeb0bbbacc..1359c82a334bd 100644 --- a/dev/tests/integration/etc/install-config-mysql.travis.php.dist +++ b/dev/tests/integration/etc/install-config-mysql.travis.php.dist @@ -9,7 +9,7 @@ return [ 'db-user' => 'travis', 'db-password' => '', 'db-name' => 'magento_integration_tests', - 'db-prefix' => 'travis_', + 'db-prefix' => 'trv_', 'backend-frontname' => 'backend', 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD, diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index 966451fb35855..769876f7e38a2 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -190,7 +190,8 @@ public function getDbInstance() if (null === $this->_db) { if ($this->isInstalled()) { $configPool = new \Magento\Framework\Config\File\ConfigFilePool(); - $reader = new Reader($this->dirList, $configPool); + $driverPool = new \Magento\Framework\Filesystem\DriverPool(); + $reader = new Reader($this->dirList, $driverPool, $configPool); $deploymentConfig = new DeploymentConfig($reader, []); $host = $deploymentConfig->get( ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/Utility/FilesTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/Utility/FilesTest.php index 2ca967abca40e..e6e430d1e3e35 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/App/Utility/FilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/App/Utility/FilesTest.php @@ -105,6 +105,21 @@ public function testGetLayoutConfigFiles() } } + public function testGetXmlCatalogFiles() + { + $actual = $this->model->getXmlCatalogFiles('*.xml'); + $this->assertNotEmpty($actual); + foreach ($actual as $file) { + $this->assertStringEndsWith('.xml', $file[0]); + } + + $actual = $this->model->getXmlCatalogFiles('*.xsd'); + $this->assertNotEmpty($actual); + foreach ($actual as $file) { + $this->assertStringEndsWith('.xsd', $file[0]); + } + } + /** * Verify that the given array of files does not contain anything in test directories * diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig.php b/lib/internal/Magento/Framework/App/DeploymentConfig.php index ef1710741d222..06784e31d2d74 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig.php @@ -6,6 +6,8 @@ namespace Magento\Framework\App; +use Magento\Framework\Config\ConfigOptionsListConstants; + /** * Application deployment configuration */ @@ -39,13 +41,6 @@ class DeploymentConfig */ private $overrideData; - /** - * Availability of deployment config file - * - * @var bool - */ - private $isAvailable; - /** * Constructor * @@ -65,7 +60,7 @@ public function __construct(DeploymentConfig\Reader $reader, $overrideData = []) * * @param string $key * @param mixed $defaultValue - * @return array|null + * @return mixed|null */ public function get($key = null, $defaultValue = null) { @@ -85,7 +80,7 @@ public function isAvailable() { $this->data = null; $this->load(); - return $this->isAvailable; + return isset($this->flatData[ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE]); } /** @@ -128,7 +123,6 @@ private function load() { if (null === $this->data) { $this->data = $this->reader->load(); - $this->isAvailable = !empty($this->data); if ($this->overrideData) { $this->data = array_replace($this->data, $this->overrideData); } diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php index 5ccb6c347c6fd..1654f98ead055 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php @@ -8,6 +8,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Config\File\ConfigFilePool; +use Magento\Framework\Filesystem\DriverPool; /** * Deployment configuration reader @@ -24,6 +25,11 @@ class Reader */ private $configFilePool; + /** + * @var DriverPool + */ + private $driverPool; + /** * Configuration file names * @@ -35,14 +41,20 @@ class Reader * Constructor * * @param DirectoryList $dirList + * @param DriverPool $driverPool * @param ConfigFilePool $configFilePool * @param null|string $file * @throws \InvalidArgumentException */ - public function __construct(DirectoryList $dirList, ConfigFilePool $configFilePool, $file = null) - { + public function __construct( + DirectoryList $dirList, + DriverPool $driverPool, + ConfigFilePool $configFilePool, + $file = null + ) { $this->dirList = $dirList; $this->configFilePool = $configFilePool; + $this->driverPool = $driverPool; if (null !== $file) { if (!preg_match('/^[a-z\d\.\-]+\.php$/i', $file)) { throw new \InvalidArgumentException("Invalid file name: {$file}"); @@ -73,23 +85,32 @@ public function getFiles() public function load($fileKey = null) { $path = $this->dirList->getPath(DirectoryList::CONFIG); + $fileDriver = $this->driverPool->getDriver(DriverPool::FILE); + $result = []; if ($fileKey) { - $result = @include $path . '/' . $this->configFilePool->getPath($fileKey); + $filePath = $path . '/' . $this->configFilePool->getPath($fileKey); + if ($fileDriver->isExists($filePath)) { + $result = include $filePath; + } } else { $configFiles = $this->configFilePool->getPaths(); + $allFilesData = []; $result = []; foreach (array_keys($configFiles) as $fileKey) { $configFile = $path . '/' . $this->configFilePool->getPath($fileKey); - $fileData = @include $configFile; + if ($fileDriver->isExists($configFile)) { + $fileData = include $configFile; + } else { + continue; + } + $allFilesData[$configFile] = $fileData; if (!empty($fileData)) { $intersection = array_intersect_key($result, $fileData); if (!empty($intersection)) { - $displayList = ''; - foreach (array_keys($intersection) as $key) { - $displayList .= $key . PHP_EOL; - } + $displayMessage = $this->findFilesWithKeys(array_keys($intersection), $allFilesData); throw new \Exception( - "Key collision! The following keys occur in multiple config files:" . PHP_EOL . $displayList + "Key collision! The following keys occur in multiple config files:" + . PHP_EOL . $displayMessage ); } $result = array_merge($result, $fileData); @@ -98,4 +119,26 @@ public function load($fileKey = null) } return $result ?: []; } + + /** + * Finds list of files that has the key + * + * @param array $keys + * @param array $allFilesData + * @return string + */ + private function findFilesWithKeys(array $keys, array $allFilesData) + { + $displayMessage = ''; + foreach ($keys as $key) { + $foundConfigFiles = []; + foreach ($allFilesData as $fileName => $fileValues) { + if (isset($fileValues[$key])) { + $foundConfigFiles[] = $fileName; + } + } + $displayMessage .= 'Key "' . $key . '" found in ' . implode(', ', $foundConfigFiles) . PHP_EOL; + } + return $displayMessage; + } } diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index 742221429db1b..0d482bf1599dd 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -202,7 +202,7 @@ protected function createDeploymentConfig( $customData = isset($arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG]) ? $arguments[self::INIT_PARAM_DEPLOYMENT_CONFIG] : []; - $reader = new DeploymentConfig\Reader($directoryList, $configFilePool, $customFile); + $reader = new DeploymentConfig\Reader($directoryList, $this->driverPool, $configFilePool, $customFile); return new DeploymentConfig($reader, $customData); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php index 04437a742a5f0..0afa1dca5c3b2 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php @@ -16,6 +16,16 @@ class ReaderTest extends \PHPUnit_Framework_TestCase */ private $dirList; + /** + * @var \Magento\Framework\Filesystem\DriverPool|\PHPUnit_Framework_MockObject_MockObject + */ + private $driverPool; + + /** + * @var \Magento\Framework\Filesystem\Driver\File|\PHPUnit_Framework_MockObject_MockObject + */ + private $fileDriver; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -28,6 +38,24 @@ protected function setUp() ->method('getPath') ->with(DirectoryList::CONFIG) ->willReturn(__DIR__ . '/_files'); + $this->fileDriver = $this->getMock('\Magento\Framework\Filesystem\Driver\File', [], [], '', false); + $this->fileDriver + ->expects($this->any()) + ->method('isExists') + ->will($this->returnValueMap([ + [__DIR__ . '/_files/config.php', true], + [__DIR__ . '/_files/custom.php', true], + [__DIR__ . '/_files/duplicateConfig.php', true], + [__DIR__ . '/_files/env.php', true], + [__DIR__ . '/_files/mergeOne.php', true], + [__DIR__ . '/_files/mergeTwo.php', true], + [__DIR__ . '/_files/nonexistent.php', false] + ])); + $this->driverPool = $this->getMock('\Magento\Framework\Filesystem\DriverPool', [], [], '', false); + $this->driverPool + ->expects($this->any()) + ->method('getDriver') + ->willReturn($this->fileDriver); $this->configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); $this->configFilePool ->expects($this->any()) @@ -37,11 +65,11 @@ protected function setUp() public function testGetFile() { - $object = new Reader($this->dirList, $this->configFilePool); + $object = new Reader($this->dirList, $this->driverPool, $this->configFilePool); $files = $object->getFiles(); $this->assertArrayHasKey('configKeyOne', $files); $this->assertArrayHasKey('configKeyTwo', $files); - $object = new Reader($this->dirList, $this->configFilePool, 'customOne.php'); + $object = new Reader($this->dirList, $this->driverPool, $this->configFilePool, 'customOne.php'); $this->assertEquals(['customOne.php'], $object->getFiles()); } @@ -51,7 +79,7 @@ public function testGetFile() */ public function testWrongFile() { - new Reader($this->dirList, $this->configFilePool, 'invalid_name'); + new Reader($this->dirList, $this->driverPool, $this->configFilePool, 'invalid_name'); } public function testLoad() @@ -61,7 +89,7 @@ public function testLoad() ->expects($this->any()) ->method('getPath') ->will($this->returnValueMap($files)); - $object = new Reader($this->dirList, $this->configFilePool); + $object = new Reader($this->dirList, $this->driverPool, $this->configFilePool); $this->assertSame(['fooKey' =>'foo', 'barKey' => 'bar', 'envKey' => 'env'], $object->load()); } @@ -75,7 +103,7 @@ public function testCustomLoad($file, $expected) $configFilePool = $this->getMock('Magento\Framework\Config\File\ConfigFilePool', [], [], '', false); $configFilePool->expects($this->any())->method('getPaths')->willReturn([$file]); $configFilePool->expects($this->any())->method('getPath')->willReturn($file); - $object = new Reader($this->dirList, $configFilePool, $file); + $object = new Reader($this->dirList, $this->driverPool, $configFilePool, $file); $this->assertSame($expected, $object->load($file)); } @@ -106,7 +134,7 @@ public function testMerging() ->expects($this->any()) ->method('getPaths') ->willReturn(['configKeyOne' => 'mergeOne.php', 'configKeyTwo' => 'mergeTwo.php']); - $object = new Reader($this->dirList, $configFilePool); + $object = new Reader($this->dirList, $this->driverPool, $configFilePool); $object->load(); } @@ -126,7 +154,7 @@ public function testMergingWithDuplicateEndValues() ->expects($this->any()) ->method('getPaths') ->willReturn(['configKeyOne' => 'config.php', 'configKeyTwo' => 'duplicateConfig.php']); - $object = new Reader($this->dirList, $configFilePool); + $object = new Reader($this->dirList, $this->driverPool, $configFilePool); $object->load(); } } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php index 913844757a6d0..59510f35918d7 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php @@ -7,6 +7,7 @@ namespace Magento\Framework\App\Test\Unit; use \Magento\Framework\App\DeploymentConfig; +use \Magento\Framework\Config\ConfigOptionsListConstants; class DeploymentConfigTest extends \PHPUnit_Framework_TestCase { @@ -88,7 +89,9 @@ public function testGetters() public function testIsAvailable() { - $this->reader->expects($this->once())->method('load')->willReturn(['a' => 1]); + $this->reader->expects($this->once())->method('load')->willReturn([ + ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE => 1 + ]); $object = new DeploymentConfig($this->reader); $this->assertTrue($object->isAvailable()); } @@ -103,7 +106,9 @@ public function testNotAvailable() public function testNotAvailableThenAvailable() { $this->reader->expects($this->at(0))->method('load')->willReturn([]); - $this->reader->expects($this->at(1))->method('load')->willReturn(['a' => 1]); + $this->reader->expects($this->at(1))->method('load')->willReturn([ + ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE => 1 + ]); $object = new DeploymentConfig($this->reader); $this->assertFalse($object->isAvailable()); $this->assertTrue($object->isAvailable()); diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php index 7802320f6fc32..79891dc769296 100644 --- a/lib/internal/Magento/Framework/App/Utility/Files.php +++ b/lib/internal/Magento/Framework/App/Utility/Files.php @@ -393,6 +393,61 @@ function ($file) use ($excludedFileNames) { } // @codingStandardsIgnoreEnd + /** + * Returns list of XML related files, used by Magento application + * + * @param string $fileNamePattern + * @param array $excludedFileNames + * @param bool $asDataSet + * @return array + */ + public function getXmlCatalogFiles( + $fileNamePattern = '*.xsd', + $excludedFileNames = [], + $asDataSet = true + ) { + $cacheKey = __METHOD__ . '|' . BP . '|' . serialize(func_get_args()); + if (!isset(self::$_cache[$cacheKey])) { + $files = $this->getFilesSubset( + $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE), + $fileNamePattern, + [] + ); + $libraryExcludeDirs = []; + foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) as $libraryDir) { + $libraryExcludeDirs[] = str_replace('\\', '/', '#' . $libraryDir . '/Test#'); + $libraryExcludeDirs[] = str_replace('\\', '/', '#' . $libraryDir) . '/[\\w]+/Test#'; + } + $files = array_merge( + $files, + $this->getFilesSubset( + $this->componentRegistrar->getPaths(ComponentRegistrar::LIBRARY), + $fileNamePattern, + $libraryExcludeDirs + ) + ); + $files = array_merge( + $files, + $this->getFilesSubset( + $this->componentRegistrar->getPaths(ComponentRegistrar::THEME), + $fileNamePattern, + [] + ) + ); + $files = array_filter( + $files, + function ($file) use ($excludedFileNames) { + return !in_array(basename($file), $excludedFileNames); + } + ); + self::$_cache[$cacheKey] = $files; + } + if ($asDataSet) { + return self::composeDataSets(self::$_cache[$cacheKey]); + } + return self::$_cache[$cacheKey]; + } + /** * Returns a list of configuration files found under theme directories. * diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php index c2c928b2376ef..44258c7f135ce 100644 --- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php +++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php @@ -48,7 +48,7 @@ public static function register($type, $componentName, $path) if (isset(self::$paths[$type][$componentName])) { throw new \LogicException('\'' . $componentName . '\' component already exists'); } else { - self::$paths[$type][$componentName] = $path; + self::$paths[$type][$componentName] = str_replace('\\', '/', $path); } } diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php index 4fbeaecc85d18..c49d92ee281ce 100644 --- a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php +++ b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php @@ -56,7 +56,6 @@ class ConfigOptionsListConstants */ const SESSION_SAVE_FILES = 'files'; const SESSION_SAVE_DB = 'db'; - const SESSION_SAVE_REDIS = 'redis'; /**#@-*/ /** diff --git a/lib/internal/Magento/Framework/Config/Dom.php b/lib/internal/Magento/Framework/Config/Dom.php index eddf5c5bd8bb2..a0fbe07e087bd 100644 --- a/lib/internal/Magento/Framework/Config/Dom.php +++ b/lib/internal/Magento/Framework/Config/Dom.php @@ -281,6 +281,7 @@ public static function validateDomDocument( } $schema = self::$urnResolver->getRealPath($schema); libxml_use_internal_errors(true); + libxml_set_external_entity_loader([self::$urnResolver, 'registerEntityLoader']); try { $result = $dom->schemaValidate($schema); $errors = []; @@ -298,6 +299,7 @@ public static function validateDomDocument( libxml_use_internal_errors(false); throw $exception; } + libxml_set_external_entity_loader(null); libxml_use_internal_errors(false); return $errors; } diff --git a/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php b/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php index e81a99ea53fec..4bc62504d253c 100644 --- a/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php +++ b/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php @@ -10,6 +10,9 @@ namespace Magento\Framework\Config\Dom; use Magento\Framework\Component\ComponentRegistrar; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NotFoundException; +use Magento\Framework\Phrase; class UrnResolver { @@ -18,42 +21,60 @@ class UrnResolver * * @param string $schema * @return string - * @throws \UnexpectedValueException + * @throws NotFoundException */ public function getRealPath($schema) { + if (strpos($schema, 'urn:') !== 0) { + return $schema; + } + $componentRegistrar = new ComponentRegistrar(); - if (substr($schema, 0, 4) == 'urn:') { - // resolve schema location - $urnParts = explode(':', $schema); - if ($urnParts[2] == 'module') { - // urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd - // 0 : urn, 1: magento, 2: module, 3: Magento_Catalog, 4: etc/catalog_attributes.xsd - // moduleName -> Magento_Catalog - $schemaPath = $componentRegistrar->getPath( - ComponentRegistrar::MODULE, - $urnParts[3] - ) . '/' . $urnParts[4]; - } else if (strpos($urnParts[2], 'framework') === 0) { - // urn:magento:framework:Module/etc/module.xsd - // 0: urn, 1: magento, 2: framework, 3: Module/etc/module.xsd - // libaryName -> magento/framework - $libraryName = $urnParts[1] . '/' . $urnParts[2]; - $schemaPath = $componentRegistrar->getPath( - ComponentRegistrar::LIBRARY, - $libraryName - ) . '/' . $urnParts[3]; - } else { - throw new \UnexpectedValueException("Unsupported format of schema location: " . $schema); - } - if (!empty($schemaPath) && file_exists($schemaPath)) { - $schema = $schemaPath; + $matches = []; + $modulePattern = '/urn:(?([a-zA-Z]*)):module:(?([A-Za-z\_]*)):(?(.+))/'; + $frameworkPattern = '/urn:(?([a-zA-Z]*)):(?(framework[A-Za-z\-]*)):(?(.+))/'; + if (preg_match($modulePattern, $schema, $matches)) { + //urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd + $package = $componentRegistrar + ->getPath(ComponentRegistrar::MODULE, $matches['module']); + } else if (preg_match($frameworkPattern, $schema, $matches)) { + //urn:magento:framework:Module/etc/module.xsd + //urn:magento:framework-amqp:Module/etc/module.xsd + $package = $componentRegistrar + ->getPath(ComponentRegistrar::LIBRARY, $matches['vendor'] . '/' . $matches['framework']); + } else { + throw new NotFoundException(new Phrase("Unsupported format of schema location: '%1'", [$schema])); + } + $schemaPath = $package . '/' . $matches['path']; + if (empty($package) || !file_exists($schemaPath)) { + throw new NotFoundException( + new Phrase("Could not locate schema: '%1' at '%2'", [$schema, $schemaPath]) + ); + } + return $schemaPath; + } + + /** + * Callback registered for libxml to resolve URN to the file path + * + * @param string $public + * @param string $system + * @param array $context + * @return resource + * @throws LocalizedException + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function registerEntityLoader($public, $system, $context) + { + if (strpos($system, 'urn:') === 0) { + $filePath = $this->getRealPath($system); + } else { + if (file_exists($system)) { + $filePath = $system; } else { - throw new \UnexpectedValueException( - "Could not locate schema: '" . $schema . "' at '" . $schemaPath . "'" - ); + throw new LocalizedException(new Phrase("File '%system' cannot be found", ['system' => $system])); } } - return $schema; + return fopen($filePath, "r"); } } diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php index 6d78174e75573..4cff9c9cc6156 100644 --- a/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php +++ b/lib/internal/Magento/Framework/Config/Test/Unit/Dom/UrnResolverTest.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\Config\Test\Unit\Dom; -use \Magento\Framework\Config\Dom\UrnResolver; +use Magento\Framework\Config\Dom\UrnResolver; use Magento\Framework\Component\ComponentRegistrar; class UrnResolverTest extends \PHPUnit_Framework_TestCase @@ -53,8 +53,8 @@ public function testGetRealPathWithModuleUrn() } /** - * @expectedException \UnexpectedValueException - * @expectedExceptionMessage Unsupported format of schema location: urn:magento:test:test:etc/test_test.xsd + * @expectedException \Magento\Framework\Exception\NotFoundException + * @expectedExceptionMessage Unsupported format of schema location: 'urn:magento:test:test:etc/test_test.xsd' */ public function testGetRealPathWrongSection() { @@ -63,7 +63,7 @@ public function testGetRealPathWrongSection() } /** - * @expectedException \UnexpectedValueException + * @expectedException \Magento\Framework\Exception\NotFoundException * @expectedExceptionMessage Could not locate schema: 'urn:magento:module:Magento_Test:test.xsd' at '/test.xsd' */ public function testGetRealPathWrongModule() diff --git a/lib/internal/Magento/Framework/Controller/Result/Json.php b/lib/internal/Magento/Framework/Controller/Result/Json.php index bc3855448ccc2..f1d480efec72e 100644 --- a/lib/internal/Magento/Framework/Controller/Result/Json.php +++ b/lib/internal/Magento/Framework/Controller/Result/Json.php @@ -63,8 +63,6 @@ public function setJsonData($jsonData) */ protected function render(ResponseInterface $response) { - // reset profiler to avoid appending profiling stat to JSON response - \Magento\Framework\Profiler::reset(); $this->translateInline->processResponseBody($this->json, true); $response->representJson($this->json); return $this; diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/_files/types_schema.xsd b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/_files/types_schema.xsd index 376f73561e6f2..45abbf27aa5bd 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Argument/_files/types_schema.xsd +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Argument/_files/types_schema.xsd @@ -9,6 +9,6 @@ */ --> - + diff --git a/lib/internal/Magento/Framework/Module/ModuleList.php b/lib/internal/Magento/Framework/Module/ModuleList.php index c5fa5ed8a3d10..fb1fb8de06d17 100644 --- a/lib/internal/Magento/Framework/Module/ModuleList.php +++ b/lib/internal/Magento/Framework/Module/ModuleList.php @@ -139,7 +139,8 @@ public function isModuleInfoAvailable() */ private function loadConfigData() { - if (null === $this->configData && ($this->config->isAvailable())) { + $this->config->resetData(); + if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) { $this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES); } } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php index d4f1af7fa8a07..7f78420c4fc99 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php @@ -47,7 +47,7 @@ protected function setUp() public function testGetAll() { - $this->config->expects($this->once())->method('isAvailable')->willReturn(true); + $this->config->expects($this->exactly(2))->method('resetData'); $this->setLoadAllExpectation(); $this->setLoadConfigExpectation(); $expected = ['foo' => self::$allFixture['foo']]; @@ -58,7 +58,6 @@ public function testGetAll() public function testGetAllNoData() { $this->loader->expects($this->exactly(2))->method('load')->willReturn([]); - $this->config->expects($this->never())->method('isAvailable'); $this->setLoadConfigExpectation(false); $this->assertEquals([], $this->model->getAll()); $this->assertEquals([], $this->model->getAll()); @@ -66,7 +65,7 @@ public function testGetAllNoData() public function testGetOne() { - $this->config->expects($this->once())->method('isAvailable')->willReturn(true); + $this->config->expects($this->exactly(2))->method('resetData'); $this->setLoadAllExpectation(); $this->setLoadConfigExpectation(); $this->assertSame(['key' => 'value'], $this->model->getOne('foo')); @@ -75,7 +74,7 @@ public function testGetOne() public function testGetNames() { - $this->config->expects($this->once())->method('isAvailable')->willReturn(true); + $this->config->expects($this->exactly(2))->method('resetData'); $this->setLoadAllExpectation(false); $this->setLoadConfigExpectation(); $this->assertSame(['foo'], $this->model->getNames()); @@ -84,7 +83,7 @@ public function testGetNames() public function testHas() { - $this->config->expects($this->once())->method('isAvailable')->willReturn(true); + $this->config->expects($this->exactly(2))->method('resetData'); $this->setLoadAllExpectation(false); $this->setLoadConfigExpectation(); $this->assertTrue($this->model->has('foo')); @@ -93,15 +92,15 @@ public function testHas() public function testIsModuleInfoAvailable() { - $this->config->expects($this->once())->method('isAvailable')->willReturn(true); + $this->config->expects($this->once())->method('resetData'); $this->setLoadConfigExpectation(true); $this->assertTrue($this->model->isModuleInfoAvailable()); } public function testIsModuleInfoAvailableNoConfig() { - $this->config->expects($this->once())->method('isAvailable')->willReturn(true); - $this->config->expects($this->once())->method('get')->willReturn(null); + $this->config->expects($this->at(0))->method('get')->willReturn(['modules' => 'testModule']); + $this->config->expects($this->at(1))->method('get')->willReturn(null); $this->assertFalse($this->model->isModuleInfoAvailable()); } @@ -114,7 +113,7 @@ public function testIsModuleInfoAvailableNoConfig() private function setLoadConfigExpectation($isExpected = true) { if ($isExpected) { - $this->config->expects($this->once())->method('get')->willReturn(self::$enabledFixture); + $this->config->expects($this->exactly(2))->method('get')->willReturn(self::$enabledFixture); } else { $this->config->expects($this->never())->method('get'); } diff --git a/lib/internal/Magento/Framework/ObjectManager/etc/config.xsd b/lib/internal/Magento/Framework/ObjectManager/etc/config.xsd index 2d47cdf0ba1ae..3b1f32f40a004 100644 --- a/lib/internal/Magento/Framework/ObjectManager/etc/config.xsd +++ b/lib/internal/Magento/Framework/ObjectManager/etc/config.xsd @@ -9,7 +9,7 @@ --> - + diff --git a/lib/internal/Magento/Framework/Search/etc/search_request.xsd b/lib/internal/Magento/Framework/Search/etc/search_request.xsd index 9a3d756e0f9b9..5b12665d43861 100644 --- a/lib/internal/Magento/Framework/Search/etc/search_request.xsd +++ b/lib/internal/Magento/Framework/Search/etc/search_request.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd index 9e20a45383848..31a5ad3494dfa 100644 --- a/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd +++ b/lib/internal/Magento/Framework/Search/etc/search_request_merged.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/lib/internal/Magento/Framework/Ui/README.md b/lib/internal/Magento/Framework/Ui/README.md deleted file mode 100644 index f955cbb0d9efd..0000000000000 --- a/lib/internal/Magento/Framework/Ui/README.md +++ /dev/null @@ -1 +0,0 @@ -Library contain schema files used to validate XML files in Magento\Ui module diff --git a/lib/internal/Magento/Framework/View/Layout/etc/body.xsd b/lib/internal/Magento/Framework/View/Layout/etc/body.xsd index 94922875f16a2..d9e83a41bf746 100755 --- a/lib/internal/Magento/Framework/View/Layout/etc/body.xsd +++ b/lib/internal/Magento/Framework/View/Layout/etc/body.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/lib/internal/Magento/Framework/View/Layout/etc/elements.xsd b/lib/internal/Magento/Framework/View/Layout/etc/elements.xsd index 2170a38073384..5bc3bfb488ebc 100755 --- a/lib/internal/Magento/Framework/View/Layout/etc/elements.xsd +++ b/lib/internal/Magento/Framework/View/Layout/etc/elements.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd b/lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd index b6ea0390d953d..d768b85945582 100755 --- a/lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd +++ b/lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/lib/internal/Magento/Framework/View/Layout/etc/layout_merged.xsd b/lib/internal/Magento/Framework/View/Layout/etc/layout_merged.xsd index 985c08c630bf9..d47f45d49f73f 100644 --- a/lib/internal/Magento/Framework/View/Layout/etc/layout_merged.xsd +++ b/lib/internal/Magento/Framework/View/Layout/etc/layout_merged.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd b/lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd index 690771f1ddafc..a3ff191d37f50 100644 --- a/lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd +++ b/lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd @@ -6,9 +6,9 @@ */ --> - - - + + + diff --git a/lib/internal/Magento/Framework/View/Layout/etc/page_layout.xsd b/lib/internal/Magento/Framework/View/Layout/etc/page_layout.xsd index d0012ffbd0f50..8231cc7778739 100755 --- a/lib/internal/Magento/Framework/View/Layout/etc/page_layout.xsd +++ b/lib/internal/Magento/Framework/View/Layout/etc/page_layout.xsd @@ -6,7 +6,7 @@ */ --> - + diff --git a/setup/pub/magento/setup/web-configuration.js b/setup/pub/magento/setup/web-configuration.js index 13ff2e05fe666..9180a727ff209 100644 --- a/setup/pub/magento/setup/web-configuration.js +++ b/setup/pub/magento/setup/web-configuration.js @@ -27,6 +27,10 @@ angular.module('web-configuration', ['ngStorage']) }, advanced: { expanded: false + }, + sessionSave: { + type: 'files', + error: false } }; diff --git a/setup/src/Magento/Setup/Controller/Install.php b/setup/src/Magento/Setup/Controller/Install.php index fe6f1f363bb7d..7a0826acc0472 100644 --- a/setup/src/Magento/Setup/Controller/Install.php +++ b/setup/src/Magento/Setup/Controller/Install.php @@ -162,6 +162,8 @@ private function importDeploymentConfigForm() ? $source['config']['address']['admin'] : ''; $result[SetupConfigOptionsList::INPUT_KEY_ENCRYPTION_KEY] = isset($source['config']['encrypt']['key']) ? $source['config']['encrypt']['key'] : null; + $result[SetupConfigOptionsList::INPUT_KEY_SESSION_SAVE] = isset($source['config']['sessionSave']['type']) + ? $source['config']['sessionSave']['type'] : SetupConfigOptionsList::SESSION_SAVE_FILES; $result[Installer::ENABLE_MODULES] = isset($source['store']['selectedModules']) ? implode(',', $source['store']['selectedModules']) : ''; $result[Installer::DISABLE_MODULES] = isset($source['store']['allModules']) diff --git a/setup/src/Magento/Setup/Controller/WebConfiguration.php b/setup/src/Magento/Setup/Controller/WebConfiguration.php index 1197a234c0ad9..ad9d3bfb1adf4 100644 --- a/setup/src/Magento/Setup/Controller/WebConfiguration.php +++ b/setup/src/Magento/Setup/Controller/WebConfiguration.php @@ -5,9 +5,10 @@ */ namespace Magento\Setup\Controller; +use Magento\Framework\App\SetupInfo; +use Magento\Framework\Config\ConfigOptionsListConstants; use Zend\Mvc\Controller\AbstractActionController; use Zend\View\Model\ViewModel; -use Magento\Framework\App\SetupInfo; class WebConfiguration extends AbstractActionController { @@ -22,7 +23,11 @@ public function indexAction() $view = new ViewModel( [ 'autoBaseUrl' => $setupInfo->getProjectUrl(), - 'autoAdminPath' => $setupInfo->getProjectAdminPath() + 'autoAdminPath' => $setupInfo->getProjectAdminPath(), + 'sessionSave' => [ + ConfigOptionsListConstants::SESSION_SAVE_FILES, + ConfigOptionsListConstants::SESSION_SAVE_DB, + ], ] ); $view->setTerminal(true); diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList.php b/setup/src/Magento/Setup/Model/ConfigOptionsList.php index bcc84dca9bd7f..fc49535e28b08 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList.php @@ -37,7 +37,6 @@ class ConfigOptionsList implements ConfigOptionsListInterface private $validSaveHandlers = [ ConfigOptionsListConstants::SESSION_SAVE_FILES, ConfigOptionsListConstants::SESSION_SAVE_DB, - ConfigOptionsListConstants::SESSION_SAVE_REDIS ]; /** diff --git a/setup/src/Magento/Setup/Model/FilePermissions.php b/setup/src/Magento/Setup/Model/FilePermissions.php index 18f6de73d4f70..16e71b2010197 100644 --- a/setup/src/Magento/Setup/Model/FilePermissions.php +++ b/setup/src/Magento/Setup/Model/FilePermissions.php @@ -109,7 +109,7 @@ public function getInstallationCurrentWritableDirectories() { if (!$this->installationCurrentWritableDirectories) { foreach ($this->installationWritableDirectories as $code => $path) { - if ($this->isWritable($code)) { + if ($this->isWritable($code) && $this->checkRecursiveDirectories($path)) { $this->installationCurrentWritableDirectories[] = $path; } } @@ -117,6 +117,26 @@ public function getInstallationCurrentWritableDirectories() return $this->installationCurrentWritableDirectories; } + /** + * Check all sub-directories + * + * @param string $directory + * @return bool + */ + private function checkRecursiveDirectories($directory) + { + $directoryIterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($directory), + \RecursiveIteratorIterator::LEAVES_ONLY | \RecursiveIteratorIterator::CATCH_GET_CHILD + ); + foreach ($directoryIterator as $subDirectory) { + if ($subDirectory->isDir() && !$subDirectory->isWritable()) { + return false; + } + } + return true; + } + /** * Retrieve list of currently non-writable directories for application * diff --git a/setup/view/magento/setup/readiness-check/progress.phtml b/setup/view/magento/setup/readiness-check/progress.phtml index 53ca61521c556..3ddb6e434f682 100755 --- a/setup/view/magento/setup/readiness-check/progress.phtml +++ b/setup/view/magento/setup/readiness-check/progress.phtml @@ -446,7 +446,9 @@

- The best way to resolve this is to allow write permissions for the following Magento directories. The exact fix depends on your server, your host, and other system variables. + The best way to resolve this is to allow write permissions for the following Magento + directories and their sub-directories. The exact fix depends on your server, your host, + and other system variables.
Our File Permission Help can get you started.

diff --git a/setup/view/magento/setup/web-configuration.phtml b/setup/view/magento/setup/web-configuration.phtml index 5101643a6defc..c8f7d0f1b5e80 100644 --- a/setup/view/magento/setup/web-configuration.phtml +++ b/setup/view/magento/setup/web-configuration.phtml @@ -61,7 +61,7 @@ $hints = [ +
+
+ +
+
+ +
+