I'm getting this error on using the duration field in a CCK node with max hours and min seconds:

warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 4 in /var/www/vhosts/fitmusic.com/httpdocs/sites/all/modules/duration/duration.inc on line 113.
warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 4 in /var/www/vhosts/fitmusic.com/httpdocs/sites/all/modules/duration/duration.inc on line 114.
warning: preg_match() [function.preg-match]: Compilation failed: unrecognized character after (?< at offset 4 in /var/www/vhosts/fitmusic.com/httpdocs/sites/all/modules/duration/duration.inc on line 115.

It works fine on the preview but fails on final submission.

Any thoughts?
Thanks

Comments

jpetso’s picture

Status: Active » Postponed (maintainer needs more info)

Could you insert the following lines just after the assignments and before the preg_match() calls? (Minus the php tags, that is.)

    drupal_set_message($des_datetime);
    drupal_set_message($alt_datetime);
    drupal_set_message($alt_datetime_ext);

I think that should be line 111. Drupal should then show the regular expressions as messages, maybe I can make some sense out of those if you copy them in here. Also... are you using PHP 5 or 4? (Maybe that makes a difference too? although I think it shouldn't.)

jpetso’s picture

Oops, wrong variable names initially. I edited the above comment, please ignore the code that a possible notification email might have sent you.

amccann’s picture

Sorry for the delay - I didn't get a notification. I've fixed that so I should get updates now.

Here is the result

/^(?\-)?P(?:(?:(?:(?(?:\d+(?:[,.]\d+)?))Y)?(?:(?:(?(?:\d+(?:[,.]\d+)?))M)|(?:(?(?:\d+(?:[,.]\d+)?))W))?(?:(?(?:\d+(?:[,.]\d+)?))D)?)?(?:T(?:(?(?:\d+(?:[,.]\d+)?))H)?(?:(?(?:\d+(?:[,.]\d+)?))M)?(?:(?(?:\d+(?:[,.]\d+)?))S)?)?)$/
/^(?\-)?P(?:(?:(?\d\d\d\d)(?:(?\d\d)(?\d\d)|(?\d\d\d)))(?:T(?\d\d)(?\d\d)(?\d\d)))$/
/^(?\-)?P(?:(?:(?\d\d\d\d)\-(?:(?\d\d)\-(?\d\d)|(?\d\d\d)))(?:T(?\d\d):(?\d\d):(?\d\d)))$/

I am on a platform with the following...
MySQL database 5.0.45
PHP 5.2.6

Thanks for your help - I will be more responsive.
Alan

jpetso’s picture

Ok, sorry for the delay (kinda busy with little time for Duration, and other modules :P ). Seeing your output, I'm noticing that it doesn't really help - not only is the regular expression (aka strange output) constructed correctly but also the tag-like pattern names (<year>, etc.) are swallowed by your browser and only visible in the HTML source.

Anyways, after a bit of googling and a short trip into the PHP documentation, I think the problem might be with those pattern names. Don't know where I've got my format from (probably from standard Perl regexp documentation, or from the Qt docs, it seems), but PHP might not interpret the pattern names as standard regexp interpreters do, or at least not on all systems (it works on mine). So please try to do the following and tell me if that fixes the error or not.

  1. You can safely get rid of the additional lines from comment #1 again.
  2. Instead, insert a "P" into all pattern names, e.g. making (?<sign>\\-) into (?P<sign>\\-) (so the "P" goes between the question mark and the less-than sign). Do this only for expressions that are actually named, e.g. for (?:(?<years>${number})Y) you would insert the "P" between the second "?" and associated "<", but the "<?:" at the start would remain unchanged. The lines that need to be changed are 73, 78-84, and 93-99.

Hope that works out, I'm curious if it does. Cannot test by myself unfortunately, so I need to ask you again to do that for me.

amccann’s picture

Status: Postponed (maintainer needs more info) » Fixed

That was the magic trick!

Thanks.

The site we are using it on is a soon to be launched update to http://fitmusic.com

jpetso’s picture

Cool. I applied the fix to CVS, so the next release (the one after 6.x-1.0-rc2) won't cause that error anymore.

jpetso’s picture

Title: Error on » preg_match() error

I thought I changed the title with the previous comment already?

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.