EllisLab text mark
Advanced Search
     
Date format variable detection missing colon from regex. Was present in previous versions.
Posted: 26 February 2014 11:43 AM
Avatar
Joined: 2006-03-13
102 posts

In

system/expressionengine/libraries/Template.php->_match_date_vars() 

In previous versions the regex for matching date fields allowed for a colon:

if (preg_match_all("/".LD."([\w:\-]+)\s+format=[\"'](.*?)[\"']".RD."/", $str$matches, PREG_SET_ORDER)) 

In EE 2.8 beta 2, the colon is removed for some reason:

if ($standard preg_match_all("/".LD."([\w\-]+)\s+(format|timezone)=[\"'](.*?)[\"']".RD."/", $str$matches, PREG_SET_ORDER)) 

I’m assuming that this is to allow for matching of the new ‘:relative’ keyword, but this breaks some longtime usage of colon prefixed vars that I know ourselves and DevDemon use off of the top of my head.

For instance: in EE 2.7.3,

{freeform:edit_date format="%Y-%m-%d"

works when using TMPL->parse_variables. In EE 2.8 it does not due to the removal of the colon from the regex.

Seth Barber
Administrator

2014-02-26 (0 votes) by Seth Barber

Thanks for catching this. I have adjusted the flow of that function catching relative dates first, and restored the colon when searching for other dates. This will be in the 2.8.0 release.

Here is the diff of the change:

diff --git a/system/expressionengine/libraries/Template.php b/system/expressionengine/libraries/Template.php
index 2c38e11
..5b54dae 100644
--- a/system/expressionengine/libraries/Template.php
+++ b/system/expressionengine/libraries/Template.php
@@ -4146,15 +4146,14 @@ class EE_Template {
    strpos
($str'timezone=') !== FALSE ||
    
strpos($str':relative') !== FALSE)
   
{
-   if ($standard preg_match_all("/".LD."([\w\-]+)\s+(format|timezone)=[\"'](.*?)[\"']".RD."/", $str$matches, PREG_SET_ORDER))
+   if (
$relative = preg_match_all("/".LD."([\w\-]+):relative(.*?)".RD."/", $str$matches, PREG_SET_ORDER))
    {
     foreach (
$matches as $match)
     {
      
$this->date_vars[] = $match[1];
     }
    }
-
-   if (
$relative = preg_match_all("/".LD."([\w\-]+):relative(.*?)".RD."/", $str$matches, PREG_SET_ORDER))
+   elseif (
$standard = preg_match_all("/".LD."([\w:\-]+)\s+(format|timezone)=[\"'](.*?)[\"']".RD."/", $str, $matches, PREG_SET_ORDER))
    {
     foreach ($matches as $match)
     { 

 Signature 

Solspace, Inc.

 
Posted: 26 February 2014 12:05 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2013-09-05
109 posts

Thanks for catching this. I have adjusted the flow of that function catching relative dates first, and restored the colon when searching for other dates. This will be in the 2.8.0 release.

Here is the diff of the change:

diff --git a/system/expressionengine/libraries/Template.php b/system/expressionengine/libraries/Template.php
index 2c38e11
..5b54dae 100644
--- a/system/expressionengine/libraries/Template.php
+++ b/system/expressionengine/libraries/Template.php
@@ -4146,15 +4146,14 @@ class EE_Template {
    strpos
($str'timezone=') !== FALSE ||
    
strpos($str':relative') !== FALSE)
   
{
-   if ($standard preg_match_all("/".LD."([\w\-]+)\s+(format|timezone)=[\"'](.*?)[\"']".RD."/", $str$matches, PREG_SET_ORDER))
+   if (
$relative = preg_match_all("/".LD."([\w\-]+):relative(.*?)".RD."/", $str$matches, PREG_SET_ORDER))
    {
     foreach (
$matches as $match)
     {
      
$this->date_vars[] = $match[1];
     }
    }
-
-   if (
$relative = preg_match_all("/".LD."([\w\-]+):relative(.*?)".RD."/", $str$matches, PREG_SET_ORDER))
+   elseif (
$standard = preg_match_all("/".LD."([\w:\-]+)\s+(format|timezone)=[\"'](.*?)[\"']".RD."/", $str, $matches, PREG_SET_ORDER))
    {
     foreach ($matches as $match)
     { 

 Signature 
 
Posted: 26 February 2014 12:05 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2006-11-30
196 posts

Hello,

This is a big issue for us. All of our addons would break. We need a workaround or have it fixed. Thanks for the catch Greg!

Brad

 Signature 

Web Development

Channel Images
Updater
Forms
Editor
Entry Mapper
Channel Files
Channel Ratings
Channel Videos
Channel Polls
Credits

 
Posted: 26 February 2014 12:06 PM   [ # 3 ]   [ Rating: 0 ]
Joined: 2006-11-30
196 posts

We posted the same minute. Thank you Seth. Could we still have a Beta 3 to test?

Brad

 Signature 

Web Development

Channel Images
Updater
Forms
Editor
Entry Mapper
Channel Files
Channel Ratings
Channel Videos
Channel Polls
Credits

 
Posted: 26 February 2014 12:07 PM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-03-13
102 posts

Thanks, Seth.

“This will be in the 2.8.0 release.”

Am I taking this to understand that there will be no third beta before release?

 Signature 

Solspace, Inc.

 
Posted: 26 February 2014 02:37 PM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2013-09-05
109 posts

I added a diff to the solution.

 Signature