Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/2.3-develop' into base-shipping-…
Browse files Browse the repository at this point in the history
…methods-checkout

# Conflicts:
#	app/code/Magento/QuoteGraphQl/Model/Cart/ExtractDataFromAddress.php
#	app/code/Magento/QuoteGraphQl/Model/Resolver/SetShippingMethodsOnCart.php
  • Loading branch information
naydav committed Mar 4, 2019
2 parents b424d79 + ef58edb commit 8b2106a
Show file tree
Hide file tree
Showing 126 changed files with 5,305 additions and 402 deletions.
6 changes: 3 additions & 3 deletions app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@
</depends>
</field>
<!--<group id="suggestions">-->
<field id="search_suggestion_enabled" translate="label comment" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="search_suggestion_enabled" translate="label comment" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable Search Suggestions</label>
<comment>When you enable this option your site may slow down.</comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="search_suggestion_count" translate="label" type="text" sortOrder="71" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="search_suggestion_count" translate="label" type="text" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Search Suggestions Count</label>
<depends>
<field id="search_suggestion_enabled">1</field>
</depends>
</field>
<field id="search_suggestion_count_results_enabled" translate="label" type="select" sortOrder="72" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="search_suggestion_count_results_enabled" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Show Results Count for Each Suggestion</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>When you enable this option your site may slow down.</comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Magento\Backend\Block\System\Design\Edit\Tab;

/**
* General system tab block.
*/
class General extends \Magento\Backend\Block\Widget\Form\Generic
{
/**
Expand Down Expand Up @@ -90,7 +93,7 @@ protected function _prepareForm()
]
);

$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
$dateFormat = $this->_localeDate->getDateFormatWithLongYear();
$fieldset->addField(
'date_from',
'date',
Expand Down
29 changes: 25 additions & 4 deletions app/code/Magento/Backup/Model/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
namespace Magento\Backup\Model;

use Magento\Backup\Helper\Data as Helper;
use Magento\Backup\Model\ResourceModel\Table\GetListTables;
use Magento\Backup\Model\ResourceModel\View\CreateViewsBackup;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\RuntimeException;

Expand Down Expand Up @@ -44,18 +46,35 @@ class Db implements \Magento\Framework\Backup\Db\BackupDbInterface
private $helper;

/**
* @param \Magento\Backup\Model\ResourceModel\Db $resourceDb
* @var GetListTables
*/
private $getListTables;

/**
* @var CreateViewsBackup
*/
private $getViewsBackup;

/**
* Db constructor.
* @param ResourceModel\Db $resourceDb
* @param \Magento\Framework\App\ResourceConnection $resource
* @param Helper|null $helper
* @param GetListTables|null $getListTables
* @param CreateViewsBackup|null $getViewsBackup
*/
public function __construct(
\Magento\Backup\Model\ResourceModel\Db $resourceDb,
ResourceModel\Db $resourceDb,
\Magento\Framework\App\ResourceConnection $resource,
?Helper $helper = null
?Helper $helper = null,
?GetListTables $getListTables = null,
?CreateViewsBackup $getViewsBackup = null
) {
$this->_resourceDb = $resourceDb;
$this->_resource = $resource;
$this->helper = $helper ?? ObjectManager::getInstance()->get(Helper::class);
$this->getListTables = $getListTables ?? ObjectManager::getInstance()->get(GetListTables::class);
$this->getViewsBackup = $getViewsBackup ?? ObjectManager::getInstance()->get(CreateViewsBackup::class);
}

/**
Expand Down Expand Up @@ -161,7 +180,7 @@ public function createBackup(\Magento\Framework\Backup\Db\BackupInterface $backu

$this->getResource()->beginTransaction();

$tables = $this->getResource()->getTables();
$tables = $this->getListTables->execute();

$backup->write($this->getResource()->getHeader());

Expand Down Expand Up @@ -198,6 +217,8 @@ public function createBackup(\Magento\Framework\Backup\Db\BackupInterface $backu
$backup->write($this->getResource()->getTableDataAfterSql($table));
}
}
$this->getViewsBackup->execute($backup);

$backup->write($this->getResource()->getTableForeignKeysSql());
$backup->write($this->getResource()->getTableTriggersSql());
$backup->write($this->getResource()->getFooter());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backup\Model\ResourceModel\Table;

use Magento\Framework\App\ResourceConnection;

/**
* Provides full list of tables in the database. This list excludes views, to allow different backup process.
*/
class GetListTables
{
private const TABLE_TYPE = 'BASE TABLE';

/**
* @var ResourceConnection
*/
private $resource;

/**
* @param ResourceConnection $resource
*/
public function __construct(ResourceConnection $resource)
{
$this->resource = $resource;
}

/**
* Get list of database tables excluding views.
*
* @return array
*/
public function execute(): array
{
return $this->resource->getConnection('backup')->fetchCol(
"SHOW FULL TABLES WHERE `Table_type` = ?",
self::TABLE_TYPE
);
}
}
116 changes: 116 additions & 0 deletions app/code/Magento/Backup/Model/ResourceModel/View/CreateViewsBackup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backup\Model\ResourceModel\View;

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Backup\Db\BackupInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;

/**
* Creates backup of Views in the database.
*/
class CreateViewsBackup
{
/**
* @var GetListViews
*/
private $getListViews;

/**
* @var ResourceConnection
*/
private $resourceConnection;

/**
* @var AdapterInterface
*/
private $connection;

/**
* @param GetListViews $getListViews
* @param ResourceConnection $resourceConnection
*/
public function __construct(
GetListViews $getListViews,
ResourceConnection $resourceConnection
) {
$this->getListViews = $getListViews;
$this->resourceConnection = $resourceConnection;
}

/**
* Write backup data to backup file.
*
* @param BackupInterface $backup
*/
public function execute(BackupInterface $backup): void
{
$views = $this->getListViews->execute();

foreach ($views as $view) {
$backup->write($this->getViewHeader($view));
$backup->write($this->getDropViewSql($view));
$backup->write($this->getCreateView($view));
}
}

/**
* Retrieve Database connection for Backup.
*
* @return AdapterInterface
*/
private function getConnection(): AdapterInterface
{
if (!$this->connection) {
$this->connection = $this->resourceConnection->getConnection('backup');
}

return $this->connection;
}

/**
* Get CREATE VIEW query for the specific view.
*
* @param string $viewName
* @return string
*/
private function getCreateView(string $viewName): string
{
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
$query = 'SHOW CREATE VIEW ' . $quotedViewName;
$row = $this->getConnection()->fetchRow($query);
$regExp = '/\sDEFINER\=\`([^`]*)\`\@\`([^`]*)\`/';
$sql = preg_replace($regExp, '', $row['Create View']);

return $sql . ';' . "\n";
}

/**
* Prepare a header for View being dumped.
*
* @param string $viewName
* @return string
*/
public function getViewHeader(string $viewName): string
{
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
return "\n--\n" . "-- Structure for view {$quotedViewName}\n" . "--\n\n";
}

/**
* Make sure that View being created is deleted if already exists.
*
* @param string $viewName
* @return string
*/
public function getDropViewSql(string $viewName): string
{
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName);
return sprintf('DROP VIEW IF EXISTS %s;\n', $quotedViewName);
}
}
44 changes: 44 additions & 0 deletions app/code/Magento/Backup/Model/ResourceModel/View/GetListViews.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Backup\Model\ResourceModel\View;

use Magento\Framework\App\ResourceConnection;

/**
* Get list of database views.
*/
class GetListViews
{
private const TABLE_TYPE = 'VIEW';

/**
* @var ResourceConnection
*/
private $resource;

/**
* @param ResourceConnection $resource
*/
public function __construct(ResourceConnection $resource)
{
$this->resource = $resource;
}

/**
* Get list of database views.
*
* @return array
*/
public function execute(): array
{
return $this->resource->getConnection('backup')->fetchCol(
"SHOW FULL TABLES WHERE `Table_type` = ?",
self::TABLE_TYPE
);
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Block/Product/View/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getAdditionalData(array $excludeAttr = [])

if (is_string($value) && strlen(trim($value))) {
$data[$attribute->getAttributeCode()] = [
'label' => __($attribute->getStoreLabel()),
'label' => $attribute->getStoreLabel(),
'value' => $value,
'code' => $attribute->getAttributeCode(),
];
Expand Down
18 changes: 16 additions & 2 deletions app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Controller\Adminhtml\Product;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\ProductFactory;
use Magento\Cms\Model\Wysiwyg as WysiwygModel;
use Magento\Framework\App\RequestInterface;
Expand All @@ -15,6 +18,11 @@
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Type as ProductTypes;

/**
* Build a product based on a request
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Builder
{
/**
Expand Down Expand Up @@ -79,10 +87,11 @@ public function __construct(
* Build product based on user request
*
* @param RequestInterface $request
* @return \Magento\Catalog\Model\Product
* @return ProductInterface
* @throws \RuntimeException
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function build(RequestInterface $request)
public function build(RequestInterface $request): ProductInterface
{
$productId = (int) $request->getParam('id');
$storeId = $request->getParam('store', 0);
Expand All @@ -92,6 +101,9 @@ public function build(RequestInterface $request)
if ($productId) {
try {
$product = $this->productRepository->getById($productId, true, $storeId);
if ($attributeSetId) {
$product->setAttributeSetId($attributeSetId);
}
} catch (\Exception $e) {
$product = $this->createEmptyProduct(ProductTypes::DEFAULT_TYPE, $attributeSetId, $storeId);
$this->logger->critical($e);
Expand All @@ -113,6 +125,8 @@ public function build(RequestInterface $request)
}

/**
* Create a product with the given properties
*
* @param int $typeId
* @param int $attributeSetId
* @param int $storeId
Expand Down
Loading

0 comments on commit 8b2106a

Please sign in to comment.