Skip to content

Commit

Permalink
Merge pull request #702 from staabm/fast-dump
Browse files Browse the repository at this point in the history
Use 8x faster mysqldump fork
  • Loading branch information
lucatume authored Mar 5, 2024
2 parents 5bf75c8 + 40a5471 commit ce5d983
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 94 deletions.
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];
$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
10 changes: 5 additions & 5 deletions tests/_data/dump.sql

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/_data/wploader-wpdb-dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ CREATE TABLE `wp_sitemeta` (

LOCK TABLES `wp_sitemeta` WRITE;
/*!40000 ALTER TABLE `wp_sitemeta` DISABLE KEYS */;
INSERT INTO `wp_sitemeta` VALUES (1,1,'user_count','1'),(2,1,'site_name','Test'),(3,1,'admin_email','admin@wordpress.test'),(4,1,'admin_user_id','1'),(5,1,'registration','none'),(6,1,'upload_filetypes','jpg jpeg png gif webp mov avi mpg 3gp 3g2 midi mid pdf doc ppt odt pptx docx pps ppsx xls xlsx key mp3 ogg flac m4a wav mp4 m4v webm ogv flv'),(7,1,'blog_upload_space','100'),(8,1,'fileupload_maxk','1500'),(9,1,'site_admins','a:1:{i:0;s:5:\"admin\";}'),(10,1,'allowedthemes','a:1:{s:17:\"twentytwentythree\";b:1;}'),(11,1,'illegal_names','a:9:{i:0;s:3:\"www\";i:1;s:3:\"web\";i:2;s:4:\"root\";i:3;s:5:\"admin\";i:4;s:4:\"main\";i:5;s:6:\"invite\";i:6;s:13:\"administrator\";i:7;s:5:\"files\";i:8;s:4:\"blog\";}'),(12,1,'wpmu_upgrade_site','53496'),(13,1,'welcome_email','Howdy USERNAME,\n\nYour new SITE_NAME site has been successfully set up at:\nBLOG_URL\n\nYou can log in to the administrator account with the following information:\n\nUsername: USERNAME\nPassword: PASSWORD\nLog in here: BLOG_URLwp-login.php\n\nWe hope you enjoy your new site. Thanks!\n\n--The Team @ SITE_NAME'),(14,1,'first_post','Welcome to %s. This is your first post. Edit or delete it, then start writing!'),(15,1,'siteurl','https://wordpress.test/'),(16,1,'add_new_users','0'),(17,1,'upload_space_check_disabled','1'),(18,1,'subdomain_install',''),(19,1,'ms_files_rewriting','0'),(20,1,'user_count',''),(21,1,'initial_db_version',''),(22,1,'active_sitewide_plugins','a:0:{}'),(23,1,'WPLANG','en_US'),(24,1,'main_site','1'),(25,1,'site_meta_supported','1');
INSERT INTO `wp_sitemeta` VALUES (1,1,'user_count','1'),(2,1,'site_name','Test'),(3,1,'admin_email','admin@wordpress.test'),(4,1,'admin_user_id','1'),(5,1,'registration','none'),(6,1,'upload_filetypes','jpg jpeg png gif webp mov avi mpg 3gp 3g2 midi mid pdf doc ppt odt pptx docx pps ppsx xls xlsx key mp3 ogg flac m4a wav mp4 m4v webm ogv flv'),(7,1,'blog_upload_space','100'),(8,1,'fileupload_maxk','1500'),(9,1,'site_admins','a:1:{i:0;s:5:\"admin\";}'),(10,1,'allowedthemes','a:1:{s:17:\"twentytwentythree\";b:1;}'),(11,1,'illegal_names','a:9:{i:0;s:3:\"www\";i:1;s:3:\"web\";i:2;s:4:\"root\";i:3;s:5:\"admin\";i:4;s:4:\"main\";i:5;s:6:\"invite\";i:6;s:13:\"administrator\";i:7;s:5:\"files\";i:8;s:4:\"blog\";}'),(12,1,'wpmu_upgrade_site','55853'),(13,1,'welcome_email','Howdy USERNAME,\n\nYour new SITE_NAME site has been successfully set up at:\nBLOG_URL\n\nYou can log in to the administrator account with the following information:\n\nUsername: USERNAME\nPassword: PASSWORD\nLog in here: BLOG_URLwp-login.php\n\nWe hope you enjoy your new site. Thanks!\n\n--The Team @ SITE_NAME'),(14,1,'first_post','Welcome to %s. This is your first post. Edit or delete it, then start writing!'),(15,1,'siteurl','https://wordpress.test/'),(16,1,'add_new_users','0'),(17,1,'upload_space_check_disabled','1'),(18,1,'subdomain_install',''),(19,1,'ms_files_rewriting','0'),(20,1,'user_count',''),(21,1,'initial_db_version',''),(22,1,'active_sitewide_plugins','a:0:{}'),(23,1,'WPLANG','en_US'),(24,1,'main_site','1'),(25,1,'site_meta_supported','1');
/*!40000 ALTER TABLE `wp_sitemeta` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -2651,4 +2651,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2024-02-20 10:26:48
-- Dump completed on 2024-03-04 9:48:36
Loading

0 comments on commit ce5d983

Please sign in to comment.