google-code-export / wordpress-custom-content-type-manager

Automatically exported from code.google.com/p/wordpress-custom-content-type-manager
2 stars 1 forks source link

Saving a text field / Date field in Mysql Date Format yyyy-mm-dd results in yyyy #563

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps:
1. Install Wordpress 3.9.1
2. Install CCTM 0.9.7.13
3. Create a Custom Text Input or Date Field with the mysql Date Format
4. Enter a date like 2014-07-23

Expected:
Should be saved as 2014-07-23 in the post

Instead:
Saved as 2014 (anything including the - is omitted)

Further testing:
The bug appears during the post submission process.
The filtering is clearing special symbols like - and + when the field contains 
numbers. if the field contains letters it saves just fine without omitting the 
symbol/s.

I could not determine if the bug is in CCTM or the result of a wordpress update.

Custom field from "Types" plugin does not have that behavior.

Tried disabling all plugins on old install and also on a clean install of 
wordpress without any plugins. Same behavior persists.

*SYSTEM INFO* 
------------------------ 
Plugin Version: 0.9.7.13-pl
WordPress Version: 3.9.1
PHP Version: 5.5.9-1ubuntu4.3
MySQL Version: 5.5.38-0ubuntu0.14.04.1
Server OS: Linux
Language: 
------------------------ 
ACTIVE PLUGINS: 
 * Custom Content Type Manager : Advanced Custom Post Types v.0.9.7.13 [http://code.google.com/p/wordpress-custom-content-type-manager/]
------------------------ 
CURRENT THEME: Twenty Fourteen v.1.1 http://wordpress.org/themes/twentyfourteen

Original issue reported on code.google.com by vr.ome...@gmail.com on 23 Jul 2014 at 11:20

GoogleCodeExporter commented 9 years ago
Update on the Issue:
Seems like wordpress saves the value in the database (wp_postmeta->meta_value) 
as it should. The bug is with displaying the field value in /wp-admin/post.php 
after submission.

Original comment by vr.ome...@gmail.com on 23 Jul 2014 at 11:44

GoogleCodeExporter commented 9 years ago

Original comment by ever...@fireproofsocks.com on 23 Jul 2014 at 2:46

GoogleCodeExporter commented 9 years ago
I took a permanent solution by adding:
if(preg_match('/((?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3}))[-:\\/.](?:[0]
?[1-9]|[1][012])[-:\\/.](?:(?:[0-2]?\\d{1})|(?:[3][01]{1})))(?![\\d])/', $str)) 
{
                $out = (array) $str;
}

into CCTM_FormElement.php (line 672)

the problem seems to be with:
$out = (array) json_decode($str, true); in function get_value();

Original comment by vr.ome...@gmail.com on 24 Jul 2014 at 9:24

GoogleCodeExporter commented 9 years ago
I too have this problem with dates that look like 1901-2014. The display in the 
EDIT shows 1901 but the database is correct after the edit with 1901-2014.

My plugin is at 0.9.7.13 and WordPress is 4.0

I added this code to line CCTM_FormElement.php (line 672) as instructed:

if(preg_match('/((?:(?:[1]{1}\\d{1}\\d{1}\\d{1})|(?:[2]{1}\\d{3}))[-:\\/.](?:[0]
?[1-9]|[1][012])[-:\\/.](?:(?:[0-2]?\\d{1})|(?:[3][01]{1})))(?![\\d])/', $str)) 
{
                $out = (array) $str;
} 

I added the line directly above:
if (!is_array($str)) {          
                $out = (array) json_decode($str, true);
            }

however, it made no change. The problem still exists.

I also found that there is no problem if I enter 1901 - 2014. Then it displays 
correctly in the Edit screen and is also correct in the database.

But, I need this problem fixed because of the large amount of data that has 
been entered into the database in the past.

Thanks

Original comment by denisone...@gmail.com on 2 Oct 2014 at 2:57