Skip to content
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

Use 8x faster mysqldump fork #702

Merged
merged 7 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"symfony/process": ">=4.4.24 <7.0",
"symfony/filesystem": ">=4.4.24 <7.0",
"vlucas/phpdotenv": "^5.0",
"ifsnop/mysqldump-php": "^2.12"
"druidfi/mysqldump-php": "^1.1"
},
"require-dev": {
"lucatume/codeception-snapshot-assertions": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion config/composer-35.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"symfony/process": ">=3.4.47 <7.0",
"symfony/filesystem": ">=3.4.47 <7.0",
"vlucas/phpdotenv": "^4.3",
"ifsnop/mysqldump-php": "^2.12"
"druidfi/mysqldump-php": "^1.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this dependency is requiring PHP 7.4+

is it fine to raise the min php version?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version 3.5 must be compatible with PHP 7.1 to 7.4, for this reason, the dependency cannot be changed.
It's fine to update master with the new solution, but 3.5 will have to keep the existing one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pushing it over the finishing line

},
"require-dev": {
"gumlet/php-image-resize": "^1.6",
Expand Down
12 changes: 3 additions & 9 deletions src/WordPress/Database/MysqlDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace lucatume\WPBrowser\WordPress\Database;

use Druidfi\Mysqldump\Mysqldump;
use Exception;
use Ifsnop\Mysqldump\Mysqldump;
use lucatume\WPBrowser\Utils\Db as DbUtil;
use lucatume\WPBrowser\Utils\Serializer;
use lucatume\WPBrowser\WordPress\DbException;
Expand Down Expand Up @@ -330,14 +330,8 @@ public function import(string $dumpFilePath): int
public function dump(string $dumpFile): void
{
try {
$dump = new class($this->dsn, $this->dbUser, $this->dbPassword) extends Mysqldump {
public function start($filename = '')
{
$this->dumpSettings['add-drop-table'] = true;
$this->dumpSettings['add-drop-database'] = true;
return parent::start($filename);
}
};
$dumpSettings = ['add-drop-table'=> true, 'add-drop-database' => true];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will the composer-35.json file use the same source code? if so, this line here might need a if-class-exist or similar construct so it works with both Mysqldump implementations?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, v3.5 is transpiled from v4 and will use the same code.
I've chased a missing db version update issue that was failing the tests, when that is solved, I will test v3.5 for issues, and will, likely put in place the conditional code.

$dump = new Mysqldump($this->dsn, $this->dbUser, $this->dbPassword, $dumpSettings);
$dump->start($dumpFile);
} catch (\Exception $e) {
throw new DbException("Failed to dump database: " . $e->getMessage(), DbException::FAILED_DUMP);
Expand Down