Skip to content

drop test tables on cleanup - #138

Open
mrxkon wants to merge 4 commits into
WordPress:masterfrom
mrxkon:cleanup-database
Open

drop test tables on cleanup#138
mrxkon wants to merge 4 commits into
WordPress:masterfrom
mrxkon:cleanup-database

Conversation

@mrxkon

@mrxkon mrxkon commented Jan 12, 2021

Copy link
Copy Markdown
Contributor

Fixes #110

Adds functionality to remove test tables from the database during cleanup.

Fixes WordPress#110

Adds functionality via `mysqli` on functions & cleanup to remove test tables from the database.
new line eof
@getsource

Copy link
Copy Markdown
Member

Thanks much for the PR!

I took a look, and I think this wouldn't work as expected when the database is only accessible from the test environment (when the test environment is not the same as the prepare one).

You can see an example in cleanup.php of how it's done for removing files.

Maybe something similar to that would work?

@mrxkon

mrxkon commented Jan 15, 2021

Copy link
Copy Markdown
Contributor Author

Hey @getsource , sure yeah, that's why I mentioned it in the issue comment since I'm only working locally :D .

If mysql is in general accessible everywhere ( since we're either way using shell_exec and other direct cli access as well ) we can go for oneliners like mysql -u $user -p$pass $db -e "drop table if exists $table;" and just iterate with that as a direct shell (and overssh) command.

This would work both locally and remotely I suppose.

@getsource

Copy link
Copy Markdown
Member

Ah, sorry, I missed the issue comment!

Yes, I think something like that makes sense. The only thing that comes to mind is that I think that would result in the MySQL password being stored in logs.

@grooverdan grooverdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could get into issues if ever $prefix needed SQL escaping, but seems unlikely.

mysql as a command generally got phased out of MariaDB-11.0+ an use mariadb instead.

MYSQL_PWD as an env variable for password still generally works, though could create a configuration file with [mysql]\npassword=.... and pass that to the command.

@kittenkamala

Copy link
Copy Markdown
Contributor

This might be mergable but I think it needs a rebase and to be tested again.

@Crixu Crixu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All looks good and straight forwards. As @kittenkamala mentioned we need some testers to run this to see if it still works

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @grooverdan, @timbutler.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: grooverdan, timbutler.

Co-authored-by: mrxkon <xkon@git.wordpress.org>
Co-authored-by: javiercasares <javiercasares@git.wordpress.org>
Co-authored-by: kittenkamala <amykamala@git.wordpress.org>
Co-authored-by: Crixu <crixu@git.wordpress.org>
Co-authored-by: getsource <kirasong@git.wordpress.org>
Co-authored-by: Ipstenu <ipstenu@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@kittenkamala kittenkamala moved this from In progress to In review in Hosting Team WCUS 2026 Aug 12, 2026
@kittenkamala kittenkamala moved this from In review to In progress in Hosting Team WCUS 2026 Aug 12, 2026
@kittenkamala kittenkamala moved this from In progress to In review in Hosting Team WCUS 2026 Aug 12, 2026

@kittenkamala kittenkamala left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you! This is failing cs tests, citing accessing the db directly. Should be updated to use $wpdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

If cleanup.php doesn't fully wipe the DB, it can cause failures.

6 participants