-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Merge Pull Request #21279 from maheshWebkul721/magento2:add-sort-order-downloadable-links - Merged commits: 1. c9a9d64 2. 92d2a3c 3. 03f0c3a 4. 81a4de8
- Loading branch information
Showing
364 changed files
with
12,803 additions
and
1,809 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
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
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
7 changes: 5 additions & 2 deletions
7
app/code/Magento/Backup/Controller/Adminhtml/Index/Create.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
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); | ||
} | ||
} |
Oops, something went wrong.