This is an old revision of the document!


Table of Contents

Upgrading from older releases

1.1.14 → 1.2.0

Entities and encodings

The biggest difference is in handling of entities. Entities are now unescaped before passing to expressions, i.e. ${php:strlen('"')} “sees” just the quote character and returns 1. In previous versions entities were passed as-is to the expressions (and that example would return 6).

Newly added unescaping of entities can expose encoding bugs. Make sure your pages declare document encoding: For XHTML it's best to send Content-Type:application/xhtml+xml;charset=UTF-8 or Content-Type:text/html;charset=UTF-8 HTTP headers.

In HTML add appropriate <meta> tag or send Content-Type:text/html;charset=UTF-8 HTTP header.

Constants

XML

Last, but not least

1.1.x → 1.1.14

In 1.1.13 translation key like <p i18n:translate="'żółw'" /> was interpreted as <p i18n:translate="'<C197><C188><C195><C179><C197><C130>w'"> and you had to use msgid "<C197><C188><C195><C179><C197><C130>w" in your .po files.

PHPTAL 1.1.14 stops doing this and keys are now left unchanged. The example above would simply expect msgid "żółw" in the .po file.

If you don't want to change your .po files and want to keep old behaviour, then call setCanonicalize(true) of PHPTAL_GetTextTranslator, e.g.:

 $translator = new PHPTAL_GetTextTranslator();
 $translator->setLanguage(…);
 $translator->setCanonicalize(true); // add this line
 $phptal->setTranslator($translator);

To upgrade templates, change <Cxxx> back to bytes. This code snippet will do it: preg_replace('/<C(\d+)>/e','chr("\1")',$po_file_content)