3 ms·
A developer at Pipdig wrote these lines of code and shipped it, I wonder how they felt. foreach ($tables as $table) { $wpdb->query("DROP TABLE $tab
by reustle 8y ago
A developer at Pipdig wrote these lines of code and shipped it, I wonder how they felt.
foreach ($tables as $table) {
$wpdb->query("DROP TABLE $table");
}
- Ayesh 8y agoWhile I don't disagree that this is horrible, perhaps the $tables array is hardcoded array.
- dajonker 8y agoIt is not, you can check the post for the full context.
- gadgetoid 8y agoOr, better still, an Archive.org snapshot of the commit that added this very code: https://web.archive.org/web/20190331195338/bitbucket.org/pipdig/p3/commits/edc47824200e15d64cab7270debc4a0526a8d323 https://web.archive.org/web/20190331195338/bitbucket.org/pip... (As a resident geek, I was asked to look into this by a friend)
- aasasd 8y agoFor good measure, the commit seems to be removed from the original repo.
- ivanhoe 8y agoIt's pretty much the same as if it was hardcoded, it drops all tables that have a name starting with the WP prefix. It's extremely ugly, but it's not unsafe (if your plan is removing all WP related tables from the DB).
- corobo 8y agoglobal $wpdb; $prefix = str_replace('_', '\_', $wpdb->prefix); $tables = $wpdb->get_col("SHOW TABLES LIKE '{$prefix}%'"); foreach ($tables as $table) { $wpdb->query("DROP TABLE $table"); } Essentially for those who aren't familiar with WordPress databases - this drops all tables relating to the WordPress install
- 29ssyg 8y agoFeels right to remind people to keep backups :P