Last active
March 9, 2019 12:56
-
-
Save crewstyle/8200905de66ea9328a754a0678c1da8f to your computer and use it in GitHub Desktop.
WordPress ~ Close database connections - #security #optimisation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Close database connections | |
* | |
* It's very dangerous to let connections opened. In a website | |
* with high traffic volume, you can kill your database just | |
* because of unclosed DB connections. | |
* This little snippet prevent that drama ;) | |
* | |
* @uses mysql_close() To close all DB connections. | |
* @see https://github.com/crewstyle/clean-wordpress | |
*/ | |
add_action('shutdown', '_cw_close_db_link', 99); | |
function _cw_close_db_link() | |
{ | |
global $wpdb; | |
unset($wpdb); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment