This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.3-develop' into base-shipping-…
…methods-checkout # Conflicts: # app/code/Magento/QuoteGraphQl/Model/Cart/ExtractDataFromAddress.php # app/code/Magento/QuoteGraphQl/Model/Resolver/SetShippingMethodsOnCart.php
- Loading branch information
Showing
126 changed files
with
5,305 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
app/code/Magento/Backup/Model/ResourceModel/Table/GetListTables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
116
app/code/Magento/Backup/Model/ResourceModel/View/CreateViewsBackup.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
44
app/code/Magento/Backup/Model/ResourceModel/View/GetListViews.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.