Vaibhav Asthana

Technology Explorer

How to hide PHP Warnings and Notices in WordPress

Loading Likes...

From time to time a user comes to me and says “I see some PHP notices and warnings on my page”.

Most of the time these are nothing to worry about (though the plugin/theme developer should know about these so that they may fix them in a future release). PHP warnings and notices are nothing to worry about on a production site most of the time.
Some of these can even be generated because the developer has to keep compatibility with older versions of WordPress as well as older PHP versions.

The solution:

If you simply set WP_DEBUG to false in your wp-config.php file you should be fine. These don’t affect your site in any way.

However, the problem is that some times the above does not work.
That can happen most times on cheap shared hosts that force displaying PHP warnings and notices.
In that case, you can replace this line from your wp-config.php file:

define('WP_DEBUG', false);

with this:

ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

I hope that helps someone out there!

MySQL Performance Tuning: Alter table querie too slow on large table

Loading Likes...

Recently I encountered one issue where I had to add index(alter table) to a column in table having 1.5 millions rows. As expected query would have taken several hours to execute so here’s the shortcut.

Alter table query would be taking several hours because it had to rewrite each of million rows with new key so quicker solution is to create an empty table apply index or alter operation then copy all data from old to new and replace it with newer table. It certainly saved atleast 2-4 hours of effort.

CREATE TABLE main_table_new LIKE main_table;
INSERT INTO main_table_new (fields_in_main_table) SELECT * FROM main_table;
RENAME TABLE main_table TO main_table_old, main_table_new TO main_table;
DROP TABLE main_table_old;

Hello world!

Loading Likes...

“Hello World!”, First set of words that most of the programmers usually print out on screen or console as part of their first coding lessons. This post is a salute from this blog to the world on its rebirth after being latent since 2009-10-26.

© 2009-2016 | All Rights Reserved | Vaibhav Asthana & Design by Anders Norén