heavenbr / wordpress-custom-content-type-manager

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

CCTM::filter('2014-09-28','datef','M d, Y') returns todays date #557

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
CCTM::filter('2014-09-28','datef','M d, Y') returns todays date

This worked fine in previous versions (0.9.7.6), returned the correct date.

Does not work in 0.9.7.13. Always returns todays date.

Original issue reported on code.google.com by mrfantsy...@gmail.com on 26 May 2014 at 8:27

GoogleCodeExporter commented 8 years ago

Original comment by ever...@fireproofsocks.com on 26 May 2014 at 9:32

GoogleCodeExporter commented 8 years ago
opk, further investigation.  It's not the version of CCTM, it's the version of 
PHP

PHP Version 5.3.10-1ubuntu3.8
var_dump of json_decode("2014-04-27",true) is NULL 
This works, since the code determines it is not valid JSON, and just returns 
the string.

However: 
PHP Version 5.5.9-1ubuntu4
var_dump of json_decode("2014-04-27",true) is int(2014) 
fails, because the result is not void, it assumes it's a multi, and the date 
will display as today's date.

The calls that are affected by this that I have found so far are on:
Line 82 of includes/CCTM_OutputFilter.php
Line 673 of includes/CCTM_FormElement.php

I fixed them in my instance by only doing the json_decode if it looks like a 
json string...

    if (!is_array($str)) {          
        $firstChar = mb_substr($str, 0, 1, 'utf-8');  // Simon Added
        if ($firstChar == '{' || $firstChar == '[') {  // Simon Added
                $out = (array) json_decode($str, true);
            }  // Simon Added
         }

Original comment by mrfantsy...@gmail.com on 28 May 2014 at 5:34

GoogleCodeExporter commented 8 years ago
Fixed in Git repo:  2796b9f..9dfda5e  master -> master

Original comment by ever...@fireproofsocks.com on 11 May 2015 at 5:28

GoogleCodeExporter commented 8 years ago
Issue 563 has been merged into this issue.

Original comment by ever...@fireproofsocks.com on 11 May 2015 at 5:31