[dokuwiki] Re: Lists plug-in : PHP 4.4.3 vs. 5.2.1

>       Curious if anyone has used the lists plug-in and experienced it killing 
> native lists format support.  I've run this plug-in for a couple of years on 
> server using PHP 4.4.3.  We recently had to move to a new server running 
> 5.2.1, which is the only difference I can find regarding DW install thus far.

Thought I'd post the solution to my own question in case others need this in 
the future.  For reasons unknown, the lists plug-in has issues under PHP 5.2.1 
with the lexer patterns that it uses in its syntax.php file, lines 81, 84, 86 & 
89 to be specific.

Original code:

81:     '\n\x20{2,}[\x2A\x2D]\s*(?=(?s).*?[^\x5C]\x3C\n\n)',
84:     '\n\x20{2,}[\x2A\x2D]\s*(?=(?s).*?[^\x5C]\x3C\n)', PLUGIN_LISTS);
86:     '\n\t+\s*[\x2A\x2D]\s*(?=(?s).*?[^\x5C]\x3C\n\n)',
89:     '\n\t+\s*[\x2A\x2D]\s*(?=(?s).*?[^\x5C]\x3C\n)', PLUGIN_LISTS);

Under PHP 5.2.1 the above will corrupt display of everything after the first 
standard list on a page.  To prevent munging of "std. list" pages replace the 
'\s*' with '\s+'.  I'm not sure what the '(?s)' portion is accomplishing as it 
doesn't seem to affect anything in my tests, so I removed this as well.

New code:

81:     '\n\x20{2,}[\x2A\x2D]\s+(?=.*?[^\x5C]\x3C\n\n)',
84:     '\n\x20{2,}[\x2A\x2D]\s+(?=.*?[^\x5C]\x3C\n)', PLUGIN_LISTS);
86:     '\n\t+\s*[\x2A\x2D]\s+(?=.*?[^\x5C]\x3C\n\n)',
89:     '\n\t+\s*[\x2A\x2D]\s+(?=.*?[^\x5C]\x3C\n)', PLUGIN_LISTS);

I successfully tested the changes against both PHP 5.2.1 and 4.4.3, so it's 
backwards compatible.  It doesn't fix the old problem of mixing list syntax on 
the same page, i.e. when a normal list is followed by a list with multi-line 
items using lists '<' syntax.  In that case you still have to put a terminating 
'<' and blank line after your normal list to prevent the lists plug-in from 
trying to treat the content between the normal list and the actual first lists 
syntax item as a multiline item.

Bobby

Other related posts: