-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database Rollback not working M2.3.0 #21151
Conversation
Hi @Stepa4man. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
app/code/Magento/Backup/Model/ResourceModel/Table/GetListTables.php
Outdated
Show resolved
Hide resolved
* @param Helper|null $helper | ||
*/ | ||
public function __construct( | ||
\Magento\Backup\Model\ResourceModel\Db $resourceDb, | ||
\Magento\Framework\App\ResourceConnection $resource, | ||
GetListTables $getListTables = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be added to end of the construct Backward Compatibility (Adding a constructor parameter)
return $this->resource->getConnection('backup')->fetchCol( | ||
"SHOW FULL TABLES WHERE `Table_type` = ?", | ||
self::TABLE_TYPE | ||
self::TABLE_TYPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate constant... Delete one please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like github's suggested change doesn't work properly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a BETA feature. Maybe sometimes doesn't work properly. Sorry
private function getShowCreateView($viewName) | ||
{ | ||
$quotedViewName = $this->getConnection()->quoteIdentifier($viewName); | ||
$query = 'SHOW CREATE VIEW ' . $quotedViewName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creating View we have to use this syntax
SQL SECURITY INVOKER
the same we do in MSI - https://github.com/magento-engcom/msi/blob/2.3-develop/app/code/Magento/InventoryCatalog/Setup/Patch/Schema/CreateLegacyStockStatusView.php#L69
https://dev.mysql.com/doc/refman/5.6/en/stored-programs-security.html
For a stored routine or view, use SQL SECURITY INVOKER in the object definition when possible so that it can be used only by users with permissions appropriate for the operations performed by the object.
In opposite case, MySQL user working with Magento would not be possible to invoke the View after creation.
This is especially affect our Cloud deployment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
If this VIEW was created with SQL SECURITY INVOKER declaration - SHOW CREATE VIEW will show SQL statement with this declaration also.
-
If no - then with SQL SECURITY DEFINER (in this example inventory_stock_2 is also VIEW and was created without SQL SECURITY INVOKER declaration)
So it's ok with the current implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, we already use SQL SECURITY INVOKER
at the time of View creation on MSI, so that backup with just pick this setting and at the time of DB restore we keep that setting
*/ | ||
class GetListTables | ||
{ | ||
const TABLE_TYPE = 'BASE TABLE'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use private constants to prevent polluting public contract with excessive obligations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
*/ | ||
class GetListViews | ||
{ | ||
const TABLE_TYPE = 'VIEW'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use private constant instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stepa4man could you please apply requested changes asap.
We really want to include this PR into Magento 2.3.1 which is being prepared and assembled literally now
Hi @Stepa4man, thank you for your contribution! |
Provided support MySQL views
Description (*)
DB backup didn't differentiate tables and views
Fixed Issues
Manual testing scenarios (*)
bin/magento setup:backup --db
bin/magento setup:rollback --db-file=db_backup_file.sql -n
Contribution checklist (*)