Wednesday, June 24, 2009

PHP regular expression failing silently due to output buffering

I just had a problem where this regexp worked for finding the option with value 'foreign-relations' but not for finding 'economy':

'#(name="Section".*<option value="(.*)" selected="selected">.*</select></p>)#s'

The result was the dreaded PHP blank page. With no errors logged.

This fixed it:

'#(name="Section".*<option value="([\w\s-]*)" selected="selected">.*</select></p>)#s'

The second version is more specific about what string will match in the value attribute and I think that when specified with .* the match filled up the entire PHP memory buffer. If so, it wasn’t logged as an error and that could be because the code here is executed in ‘output buffering’ mode, following an ob_start() call. A guess, but if I am right that might help to avoid a lot of aggravation in future. [nb PHP: not providing error output is Bad.]

Corrections to this assumption welcome!

Labels:

Wednesday, June 10, 2009

Meanwhile in South America…

Protests descend into murder following the grant of massive mineral extraction concessions in the Amazon region by the government of Peru.

Labels:

Wednesday, June 03, 2009

BCS helps UK understand personal data guardianship principles

The British Computer Society has published a code of practice for people who work with personal data. There are quite a lot of people working with our personal data, and we know that some have been negligent in the past. Government agencies in particular sometimes seem to encourage their employees to burn CD- and DVDROMs loaded with information that they are not allowed to distribute and leave them in public places such as railway carriages; but there are lots of other insidious ways in which such information might pass from legitimate into illegitimate use.

This code digests UK law and provides guidance that to my eye is simple enough for even the most harried civil servant to understand. I hope sections like Responsibilities of the data handler will be pinned up in the offices where those CDs and DVDs are burned. The code may also be of interest to anybody who is concerned about the way that personal data is being collected and used in the UK. Its weakness may be the use of terms such as ‘responsibility’ which seem not to be understood and applied by all of us in the same way.

Labels: , , ,

TCO