Summary: Fixes for PHP 5.4
Created: 2012-07-16 04:32
Status: Closed - fixed for 2.2.40
Category: PHP Compatibility
From: Petko
Priority: 4
Version: latest


PHP 5.4 introduces some changes which may cause existing PmWiki installations to break. This page tries to collect these issues which should be dealt with higher priority.

htmlspecialchars() requires a valid charset

It appears that a change for htmlspecialchars() in PHP 5.4 which expects a different default encoding, switched from ISO8859-1 to UTF-8. When the input contains invalid UTF-8 characters, it just returns an empty string.



Since version 2.2.40, PmWiki provides a helper function PHSC() fixing the problem with htmlspecialchars(). To use it in your recipes, just replace all calls to htmlspecialchars() with calls to PHSC().

Optional. In order for your recipe to work with earlier PmWiki, you can add the following snippet to it:

if(! function_exists('PHSC')) {
  function PHSC($x, $flags=ENT_COMPAT, $enc=null) { # for PHP 5.4
    if(is_null($enc)) $enc = $GLOBALS['Charset'];
    return htmlspecialchars($x, $flags, $enc);

Cookbook:SimultaneousEdits "Assigning the return value of new by reference"

(Also reported for some versions of PHP 5.3) It may be hard to have a single version compatible with both PHP 4 and PHP 5.

Thinking about simultaneous edit for a little while, perhaps it would be a possible workaround for those that don't have access to diff3, to have on a conflict, two windows in the same edit area, one showing the last edit and other showing your own changes to the wikipage. So with visual inspection, you could manually merge the differences. It would look like your translation recipe a bit (where is it, that I can't find it anywhere... is it named i9n?). Just a tought really, but I would like to see your comment about it as I'll maybe try to do it. CarlosAB July 16, 2012, at 12:05 PM

In its dark years, Wikipedia worked that way. The main edit textarea contained the last saved text, and below, a read only textarea with the posted content by the editor, who could copy chunks of it and merge them to the text. It is a good idea, if no diff3 utility or library can be used. --Petko July 16, 2012, at 04:08 PM

I did the script, it is not the most beautiful thing in the world, but works and it is really small. I also tested it a bit. One can find it here to use it and improve it. CarlosAB July 18, 2012, at 03:12 AM

Cookbook:SimultaneousEdits should be fixed as of today, otherwise please report at 01375. --Petko February 15, 2016, at 04:13 PM