Skip to content

Bug: 'include-tables' list is cleared during validation, resulting in full database dump #75

@nagyimre1980

Description

@nagyimre1980

Description

I encountered an issue where the include-tables setting is ignored during the dump process. Even when I specify a single table to dump, the script attempts to dump the entire database (all tables).

Root Cause Analysis
I believe I found the logic error in src/Druidfi/Mysqldump/Mysqldump.php within the getDatabaseStructureTables() method.

The code iterates through the tables found in the database and removes them from the $includedTables local array (presumably to check if any requested tables are missing later). However, at the end of the method, it overwrites the global settings with this modified (emptied) array.

Code Reference:
In src/Druidfi/Mysqldump/Mysqldump.php:

// Around line 297 if (in_array($name, $includedTables, true)) { $elem = array_search($name, $includedTables, true); if ($elem !== false) { unset($includedTables[$elem]); // The table is removed from the local list here } }

And then a few lines later:
// Around line 302 // The settings are updated with the remaining (missing) tables, // effectively removing the valid tables from the configuration. $this->settings->setIncludedTables($includedTables);

Consequence
By the time start() proceeds to dump the data, getIncludedTables() returns an empty array (or only invalid tables), causing the subsequent logic to fail to filter the tables correctly, often resulting in a full backup instead of a partial one.

Suggested Fix
The setIncludedTables call at the end of getDatabaseStructureTables should be removed, or the validation logic should use a temporary variable without modifying the main settings object.

For example, removing/commenting out this line fixes the issue:

// $this->settings->setIncludedTables($includedTables);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions