CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • r40475 breaks token replacement - it may break hearts
Pages: [1]

Author Topic: r40475 breaks token replacement - it may break hearts  (Read 1325 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
r40475 breaks token replacement - it may break hearts
June 20, 2012, 08:55:08 pm
I noticed a problem in 4.1.3 that may represent a lot of broken code.

I noticed that token replacement worked in the Text part of a Scheduled Reminder Email but not the HTML part. See http://forum.civicrm.org/index.php/topic,25025.0.html

I've tracked that down to a change in line 162 of CRM/Utils/Token.php. This change was made as part of r40475 which is a code reformatting change.

My concern is that this might be a symptom of a wide set of unintended changes that will cause all sorts of random havoc.

Here's the change...
Code: [Select]
-        return preg_match("/(^|[^\{])$token/", $str);
+    return preg_match("/(^|[^\{]) $token/", $str);

Note that the indentation has been fixed (good) but a space has been inserted into the regular expression (bad).

I'm assuming this is not an intended consequence of implementing a coding standard.

I suggest this needs an urgent review,

Ken

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: r40475 breaks token replacement - it may break hearts
June 20, 2012, 09:15:45 pm
I started looking at the changes made by r40475 and rapidly got daunted.

It just seems a bit odd that a code formatting tool would reach inside a string and change it.

Perhaps the key is to investigate why it did that in this case. That might offer clues about why this happened, and if there is other code effected.

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: r40475 breaks token replacement - it may break hearts
June 21, 2012, 05:04:34 am
BTW I notice the fix for http://issues.civicrm.org/jira/browse/CRM-10389 is due to a similar problem where a PHP string was modified by the code formatter. (The string was Javascript code.)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: r40475 breaks token replacement - it may break hearts
June 21, 2012, 06:34:20 am

Can you please file an issue for this

we'll do a search and check across the entire code base

yeah too bad the coder module did such awful things :( It was a fairly big commit and we are past the revert stage no

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: r40475 breaks token replacement - it may break hearts
June 22, 2012, 08:50:24 am

filed and fixed here:

http://issues.civicrm.org/jira/browse/CRM-10431

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: r40475 breaks token replacement - it may break hearts
June 23, 2012, 01:48:25 am
Thanks, Lobo!

How did you review that so promptly? (I'm impressed because the diff file for r40475 was greater than 27Mb! Are you a speed reader? ;-)

Ken

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: r40475 breaks token replacement - it may break hearts
June 23, 2012, 07:28:29 am

grep is your friend :)

i restricted my search to all preg_* functions

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • r40475 breaks token replacement - it may break hearts

This forum was archived on 2017-11-26.