Forums

data_republish.php: Notice: Undefined offset: 2

bytekultur 17 Dec, 2012
Hi all,

I have found an output in libraries/data_republish.php of an undefined offset 2 for $matches_value[2].

I haven't had time to test all cases but it seems a bug as this code could be triggered when $matches_value[2] might not be set.

This is my proposal (commented out original code at the end):
$optionmatch = $matches_option; //preg_replace('/<option(.*?)>/is', '<option value="'.$matches_value[2].'">', $matches_option);


Best regards,
Terry

PS: I am using Chronoforms V4_RC3.5.2 on Joomla 2.5.8 (for J1.6)
GreyHead 19 Dec, 2012
Hi Terry,

I'm not sure that your fix will work in every case :-(

It looks as though the problem occurs when the value is empty e.g. value='' and that capturing group [2] doesn't exist. There needs to be a check that $matches_value[2] is set. I'd add this after the pregmatch line
if ( !isset($matches_value[2]) ) {
  $matches_value[2] = '';
}

Bob

PS I'll add this to the Bugs list post
This topic is locked and no more replies can be posted.