Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've added $this->query("set session wait_timeout=600"); into wp-includes/wp-db.php file because of "MySQL has gone away" errors in every query and I need to find some way to do the changes in file persistent (I suppose update of WordPress rewrites wp-db.php file).

Any ideas?

Thanks

share|improve this question
add comment

2 Answers 2

Not a good idea to modify core WP files. Figure out the issue with the MySQL server dying: it's going to be lack of good server configuration, a (very) bad quality host or a theme that is very database query-intensive.

Fixing the underlying cause of the database server errors is the best thing to do in the long run; hacking core files is a bad, temporary fix.

share|improve this answer
add comment

Of course, WordPress overwrites its own Core file on update. That is why you don't hack them.

I am not exactly sure where you have inserted that code, but I suspect it may be in several places.

My first though is "talk to your host" or "adjust the global MySQL settings" (if you can). And of course, fix your site. There is almost certainly some poor quality code.

If you really must run an altered database object copy the whole wp-db.php file to wp-content/db.php and make your edits there. WordPress will load the altered file instead. It is called a "drop-in". This is a last resort. It really shouldn't be necessary on a decent host with decent code, and using a "drop-in" for this kind of hack is probably an abuse of the concept.

share|improve this answer
    
"drop-in" files are very interesting; I didn't know that. –  songdogtech Jan 22 at 15:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.