Differences

This shows you the differences between two versions of the page.

upgrading [2024/09/04 20:39]
2605:7980:0:208d::1 1
upgrading [2024/09/05 07:00] (current)
2605:7980:0:208d::1 1
Line 1: Line 1:
 +317
317 317
Line 28: Line 29:
==== Entities and encodings ==== ==== 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'').+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: 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. 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.
  * Don't use ''text/xml'' MIME type, use ''application/xml'' instead.   * Don't use ''text/xml'' MIME type, use ''application/xml'' instead.
-In HTML add appropriate ''<meta>'' tag or send ''Content-Type:text/html;charset=UTF-8'' HTTP header.+In HTML add appropriate ''&amp;lt;meta&amp;gt;'' tag or send ''Content-Type:text/html;charset=UTF-8'' HTTP header.
-  * If you're not using UTF-8 encoding, you must set encoding you use via ''%%$phptal->setEncoding('ISO-8859-…')%%'' (or just switch to UTF-8 already! :)+  * If you're not using UTF-8 encoding, you must set encoding you use via ''%%$phptal-&amp;gt;setEncoding('ISO-8859-…')%%'' (or just switch to UTF-8 already! :)
  * Only some 8-bit-based encodings are supported. If your encoding is not supported, you may get away with setting ISO-8859-1 instead.   * Only some 8-bit-based encodings are supported. If your encoding is not supported, you may get away with setting ISO-8859-1 instead.
Line 41: Line 42:
==== Constants ==== ==== Constants ====
-  * All constants except ''PHPTAL_VERSION'' have been removed. Remove any PHPTAL-specific ''define()''s and use class methods (available in earlier versions too) for configuration (e.g. ''%%$phptal->setPhpCodeDestination('/tmp/phptal/')%%'' for custom temp directory.)+  * All constants except ''PHPTAL_VERSION'' have been removed. Remove any PHPTAL-specific ''define()''s and use class methods (available in earlier versions too) for configuration (e.g. ''%%$phptal-&amp;gt;setPhpCodeDestination('/tmp/phptal/')%%'' for custom temp directory.)
  * ''PHPTAL_DIR'' is gone. PHPTAL now temporarily modifies ''include_path'' (this may change in the future).   * ''PHPTAL_DIR'' is gone. PHPTAL now temporarily modifies ''include_path'' (this may change in the future).
Line 50: Line 51:
  * XML namespace of ''phptal:*'' attributes has changed from ''%%http://xml.zope.org/namespaces/phptal%%'' to ''%%http://phptal.org/ns/phptal%%''.   * XML namespace of ''phptal:*'' attributes has changed from ''%%http://xml.zope.org/namespaces/phptal%%'' to ''%%http://phptal.org/ns/phptal%%''.
-  * Comments are required to be well-formed (''%%--%%'' is not allowed in comments.) Comments starting with ''%%<!--!%%'' are stripped from output. +  * Comments are required to be well-formed (''%%--%%'' is not allowed in comments.) Comments starting with ''%%&amp;lt;!--!%%'' are stripped from output. 
-  * Duplicate attributes are not allowed and they must be separated with space. ''<b title=""title="">'' is doubly wrong.+  * Duplicate attributes are not allowed and they must be separated with space. ''&amp;lt;b title=""title=""&amp;gt;'' is doubly wrong.
==== Other issues ==== ==== Other issues ====
Line 61: Line 62:
===== 1.1.x → 1.1.14 ===== ===== 1.1.x → 1.1.14 =====
-In 1.1.13 translation key like ''%%&lt;p i18n:translate="'żółw'" /&gt;%%'' was interpreted as ''%%&lt;p i18n:translate="'&lt;C197&gt;&lt;C188&gt;&lt;C195&gt;­&lt;C179&gt;&lt;C197&gt;&lt;C130&gt;w'"&gt;%%'' and you had to use ''msgid "&lt;C197&gt;&lt;C188&gt;&lt;C195&gt;­&lt;C179&gt;&lt;C197&gt;&lt;C130&gt;w"'' in your ''.po'' files.+In 1.1.13 translation key like ''%%&amp;amp;lt;p i18n:translate="'żółw'" /&amp;amp;gt;%%'' was interpreted as ''%%&amp;amp;lt;p i18n:translate="'&amp;amp;lt;C197&amp;amp;gt;&amp;amp;lt;C188&amp;amp;gt;&amp;amp;lt;C195&amp;amp;gt;­&amp;amp;lt;C179&amp;amp;gt;&amp;amp;lt;C197&amp;amp;gt;&amp;amp;lt;C130&amp;amp;gt;w'"&amp;amp;gt;%%'' and you had to use ''msgid "&amp;amp;lt;C197&amp;amp;gt;&amp;amp;lt;C188&amp;amp;gt;&amp;amp;lt;C195&amp;amp;gt;­&amp;amp;lt;C179&amp;amp;gt;&amp;amp;lt;C197&amp;amp;gt;&amp;amp;lt;C130&amp;amp;gt;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. 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.
Line 68: Line 69:
   $translator = new PHPTAL_GetTextTranslator();    $translator = new PHPTAL_GetTextTranslator();
-   $translator-&gt;setLanguage(…); +   $translator-&amp;amp;gt;setLanguage(…); 
-   $translator-&gt;setCanonicalize(true); // add this line +   $translator-&amp;amp;gt;setCanonicalize(true); // add this line 
-   $phptal-&gt;setTranslator($translator);+   $phptal-&amp;amp;gt;setTranslator($translator);
-To upgrade templates, change ''&lt;Cxxx&gt;'' back to bytes. This code snippet will do it: ''%%preg_replace('/&lt;C(\d+)&gt;/e','chr("\1")',$po_file_content)%%''+To upgrade templates, change ''&amp;amp;lt;Cxxx&amp;amp;gt;'' back to bytes. This code snippet will do it: ''%%preg_replace('/&amp;amp;lt;C(\d+)&amp;amp;gt;/e','chr("\1")',$po_file_content)%%'' 
 + 
 +1
1 1