mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-09-27 21:40:53 +02:00
Replace '0000-00-00 00:00:00' with NOW() in UPDATE
As in INSERT statements, '0000-00-00 00:00:00' needs to be replaced with a value that can be stored in PostgreSQL to avoid errors such as: Error running : UPDATE `wp_posts` SET `post_author` = 2, `post_date` = '2015-06-03 03:13:45', `post_date_gmt` = '0000-00-00 00:00:00', `post_content` = 'eyJpZF9maWVsZCI6IklEIiwiX19kZWZhdWx0c19zZXQiOnRydWV9', `post_content_filtered` = 'eyJpZF9maWVsZCI6IklEIiwiX19kZWZhdWx0c19zZXQiOnRydWV9', `post_title` = 'Untitled ngg_pictures', `post_excerpt` = '', `post_status` = 'draft', `post_type` = 'ngg_pictures', `comment_status` = 'closed', `ping_status` = 'closed', `post_password` = '', `post_name` = 'mixin_nextgen_table_extras', `to_ping` = '', `pinged` = '', `post_modified` = '2015-06-03 03:13:45', `post_modified_gmt` = '2015-06-03 09:13:45', `post_parent` = 0, `menu_order` = 0, `post_mime_type` = '', `guid` = 'https://example.com/?post_type=ngg_pictures&p=237' WHERE `ID` = 237 ---- converted to ---- UPDATE wp_posts SET post_author = 2, post_date = '2015-06-03 03:13:45', post_date_gmt = '0000-00-00 00:00:00', post_content = 'eyJpZF9maWVsZCI6IklEIiwiX19kZWZhdWx0c19zZXQiOnRydWV9', post_content_filtered = 'eyJpZF9maWVsZCI6IklEIiwiX19kZWZhdWx0c19zZXQiOnRydWV9', post_title = 'Untitled ngg_pictures', post_excerpt = '', post_status = 'draft', post_type = 'ngg_pictures', comment_status = 'closed', ping_status = 'closed', post_password = '', post_name = 'mixin_nextgen_table_extras', to_ping = '', pinged = '', post_modified = '2015-06-03 03:13:45', post_modified_gmt = '2015-06-03 09:13:45', post_parent = 0, menu_order = 0, post_mime_type = '', guid = 'https://example.com/?post_type=ngg_pictures&p=237' WHERE "ID" = 237 ----> ERROR: date/time field value out of range: "0000-00-00 00:00:00" LINE 1: ...ost_date = '2015-06-03 03:13:45', post_date_gmt = '0000-00-0... Match the INSERT behavior and replace it with NOW() in the GMT timezone. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This commit is contained in:
@@ -303,6 +303,9 @@
|
||||
$pattern = '/[ ]*`([^` ]+)`[ ]*=/';
|
||||
$sql = preg_replace( $pattern, ' $1 =', $sql);
|
||||
|
||||
// Those are used when we need to set the date to now() in gmt time
|
||||
$sql = str_replace( "'0000-00-00 00:00:00'", 'now() AT TIME ZONE \'gmt\'', $sql);
|
||||
|
||||
// For correct ID quoting
|
||||
$pattern = '/[ ]*([^ ]*ID[^ ]*)[ ]*=/';
|
||||
$sql = preg_replace( $pattern, ' "$1" =', $sql);
|
||||
|
Reference in New Issue
Block a user