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 5 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [unreleased] Unreleased

### Changed

- Replace `ifsnop/mysqldump-php` with `druidfi/mysqldump-php` for better performance (thanks @staabm).

## [4.1.0] 2024-02-20;

### Changed
Expand Down
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
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
Loading