migration-110.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 20142 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="migration.110">
  5. <title>Zend Framework 1.10</title>
  6. <para>
  7. Lors de la migration d'un version précédente vers Zend Framework 1.10 ou plus récent
  8. vous devriez prendre note de ce qui suit.
  9. </para>
  10. <sect2 id="migration.110.zend.feed.reader">
  11. <title>Zend_Feed_Reader</title>
  12. <para>
  13. With the introduction of Zend Framework 1.10, <classname>Zend_Feed_Reader</classname>'s
  14. handling of retrieving Authors and Contributors was changed, introducing
  15. a break in backwards compatibility. This change was an effort to harmonise
  16. the treatment of such data across the RSS and Atom classes of the component
  17. and enable the return of Author and Contributor data in more accessible,
  18. usable and detailed form. It also rectifies an error in that it was assumed
  19. any author element referred to a name. In RSS this is incorrect as an
  20. author element is actually only required to provide an email address.
  21. In addition, the original implementation applied its RSS limits to Atom
  22. feeds significantly reducing the usefulness of the parser with that format.
  23. </para>
  24. <para>
  25. The change means that methods like <methodname>getAuthors()</methodname>
  26. and <methodname>getContributors</methodname> no longer return a simple array
  27. of strings parsed from the relevant RSS and Atom elements. Instead, the return
  28. value is an <classname>ArrayObject</classname> subclass called
  29. <classname>Zend_Feed_Reader_Collection_Author</classname> which simulates
  30. an iterable multidimensional array of Authors. Each member of this object
  31. will be a simple array with three potential keys (as the source data permits).
  32. These include: name, email and uri.
  33. </para>
  34. <para>
  35. The original behaviour of such methods would have returned a simple
  36. array of strings, each string attempting to present a single name, but
  37. in reality this was unreliable since there is no rule governing the format
  38. of RSS Author strings.
  39. </para>
  40. <para>
  41. The simplest method of simulating the original behaviour of these
  42. methods is to use the <classname>Zend_Feed_Reader_Collection_Author</classname>'s
  43. <methodname>getValues()</methodname> which also returns a simple array of strings
  44. representing the "most relevant data", for authors presumed to be their name.
  45. Each value in the resulting array is derived from the "name" value
  46. attached to each Author (if present). In most cases this simple change is
  47. easy to apply as demonstrated below.
  48. </para>
  49. <programlisting language="php"><![CDATA[
  50. /**
  51. * Before 1.10
  52. */
  53. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  54. $authors = $feed->getAuthors();
  55. /**
  56. * With 1.10
  57. */
  58. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  59. $authors = $feed->getAuthors()->getValues();
  60. ]]></programlisting>
  61. </sect2>
  62. <sect2 id="migration.110.zend.file.transfer">
  63. <title>Zend_File_Transfer</title>
  64. <sect3 id="migration.110.zend.file.transfer.files">
  65. <title>Security change</title>
  66. <para>
  67. For security reasons <classname>Zend_File_Transfer</classname> does no longer store
  68. the original mimetype and filesize which is given from the requesting client into
  69. its internal storage. Instead the real values will be detected at initiation.
  70. </para>
  71. <para>
  72. Additionally the original values within <varname>$_FILES</varname> will be
  73. overridden within the real values at initiation. This makes also
  74. <varname>$_FILES</varname> secure.
  75. </para>
  76. <para>
  77. When you are in need of the original values you can eighter store them before
  78. initiating <classname>Zend_File_Transfer</classname> or use the
  79. <property>disableInfos</property> option at initiation. Note that this option is
  80. useless when its given after initiation.
  81. </para>
  82. </sect3>
  83. <sect3 id="migration.110.zend.file.transfer.count">
  84. <title>Count validation</title>
  85. <para>
  86. Before release 1.10 the <classname>MimeType</classname> validator used a wrong
  87. naming. For consistency the following constants have been changed:
  88. </para>
  89. <table id="migration.110.zend.file.transfer.count.table">
  90. <title>Changed Validation Messages</title>
  91. <tgroup cols="4">
  92. <thead>
  93. <row>
  94. <entry>Old</entry>
  95. <entry>New</entry>
  96. <entry>Value</entry>
  97. </row>
  98. </thead>
  99. <tbody>
  100. <row>
  101. <entry><constant>TOO_MUCH</constant></entry>
  102. <entry><constant>TOO_MANY</constant></entry>
  103. <entry>
  104. Too many files, maximum '%max%' are allowed but '%count%' are given
  105. </entry>
  106. </row>
  107. <row>
  108. <entry><constant>TOO_LESS</constant></entry>
  109. <entry><constant>TOO_FEW</constant></entry>
  110. <entry>
  111. Too few files, minimum '%min%' are expected but '%count%' are given
  112. </entry>
  113. </row>
  114. </tbody>
  115. </tgroup>
  116. </table>
  117. <para>
  118. When you are translating these messages within your code then use the new constants.
  119. As benefit you don't need to translate the original string anymore to get a correct
  120. spelling.
  121. </para>
  122. </sect3>
  123. </sect2>
  124. <sect2 id="migration.110.zend.filter.html-entities">
  125. <title>Zend_Filter_HtmlEntities</title>
  126. <para>
  127. In order to default to a more secure character encoding,
  128. <classname>Zend_Filter_HtmlEntities</classname> now defaults to <acronym>UTF-8</acronym>
  129. instead of <acronym>ISO-8859-1</acronym>.
  130. </para>
  131. <para>
  132. Additionally, because the actual mechanism is dealing with character encodings and not
  133. character sets, two new methods have been added, <methodname>setEncoding()</methodname>
  134. and <methodname>getEncoding()</methodname>. The previous methods
  135. <methodname>setCharSet()</methodname> and <methodname>setCharSet()</methodname> are now
  136. deprecated and proxy to the new methods. Finally, instead of using the protected members
  137. directly within the <methodname>filter()</methodname> method, these members are
  138. retrieved by their explicit accessors. If you were extending the filter in the past,
  139. please check your code and unit tests to ensure everything still continues to work.
  140. </para>
  141. </sect2>
  142. <sect2 id="migration.110.zend.filter.strip-tags">
  143. <title>Zend_Filter_StripTags</title>
  144. <para>
  145. <classname>Zend_Filter_StripTags</classname> contains a flag,
  146. <varname>commentsAllowed</varname>, that, in previous versions, allowed you to
  147. optionally whitelist HTML comments in HTML text filtered by the class. However, this
  148. opens code enabling the flag to <acronym>XSS</acronym> attacks, particularly in Internet
  149. Explorer (which allows specifying conditional functionality via HTML comments). Starting
  150. in version 1.9.7 (and backported to versions 1.8.5 and 1.7.9), the
  151. <varname>commentsAllowed</varname> flag no longer has any meaning, and all HTML
  152. comments, including those containing other HTML tags or nested commments, will be
  153. stripped from the final output of the filter.
  154. </para>
  155. </sect2>
  156. <sect2 id="migration.110.zend.translate">
  157. <title>Zend_Translate</title>
  158. <sect3 id="migration.110.zend.translate.xliff">
  159. <title>Xliff adapter</title>
  160. <para>
  161. In past the Xliff adapter used the source string as message Id. According to the
  162. Xliff standard the trans-unit Id should be used. This behaviour was corrected with
  163. Zend Framework 1.10. Now the trans-unit Id is used as message Id per default.
  164. </para>
  165. <para>
  166. But you can still get the incorrect and old behaviour by setting the
  167. <property>useId</property> option to <constant>FALSE</constant>.
  168. </para>
  169. <programlisting language="php"><![CDATA[
  170. $trans = new Zend_Translate('xliff', '/path/to/source', $locale, array('useId' => false));
  171. ]]></programlisting>
  172. </sect3>
  173. </sect2>
  174. <sect2 id="migration.110.zend.validate">
  175. <title>Zend_Validate</title>
  176. <sect3 id="migration.110.zend.validate.selfwritten">
  177. <title>Adaptateurs personnels</title>
  178. <para>
  179. Lorsqu'une erreur apparait dans un adaptateur crée de toute pièce,
  180. <methodname>_error()</methodname> doit être appelée. Avant Zend Framework 1.10, il était
  181. possible d'appeler cette méthode sans aucun paramètre. Le premier template de message d'erreur
  182. était alors utilisé.
  183. </para>
  184. <para>
  185. Ce comportement est problématique lorsque vous avez des validateurs retournant plusieurs messages.
  186. Aussi, étendre un validateur peut mener à des comportements inattendus dans une telle situation,
  187. comme par exemple l'apparition du mauvais message d'erreur.
  188. </para>
  189. <programlisting language="php"><![CDATA[
  190. My_Validator extends Zend_Validate_Abstract
  191. {
  192. public isValid($value)
  193. {
  194. ...
  195. $this->_error(); // Résultat inattendu
  196. ...
  197. }
  198. }
  199. ]]></programlisting>
  200. <para>
  201. Pour éviter ces problèmes <methodname>_error()</methodname> doit desormais
  202. prendre obligatoirement un paramètre.
  203. </para>
  204. <programlisting language="php"><![CDATA[
  205. My_Validator extends Zend_Validate_Abstract
  206. {
  207. public isValid($value)
  208. {
  209. ...
  210. $this->_error(self::MY_ERROR); // Ok, erreur définie
  211. ...
  212. }
  213. }
  214. ]]></programlisting>
  215. </sect3>
  216. <sect3 id="migration.110.zend.validate.datevalidator">
  217. <title>Simplification dans le validateur des dates</title>
  218. <para>
  219. Avant Zend Framework 1.10, 2 messages identiques étaient envoyés dans le validateur
  220. des dates. <constant>NOT_YYYY_MM_DD</constant> et
  221. <constant>FALSEFORMAT</constant>. Depuis Zend Framework 1.10, seul
  222. <constant>FALSEFORMAT</constant> sera retourné lorsque la date passée ne correspond pas
  223. au format demandé.
  224. </para>
  225. </sect3>
  226. <sect3 id="migration.110.zend.validate.barcodevalidator">
  227. <title>Corrections dans Alpha, Alnum et Barcode</title>
  228. <para>
  229. Avant Zend Framework 1.10, les messages dans les 2 validateurs barcode, le Alpha
  230. et le Alnum étaient identiques. Des problèmes pouvaient alors faire surface avec des
  231. messages personnalisés, des traducteurs ou des instances multiples des validateurs.
  232. </para>
  233. <para>
  234. Depuis Zend Framework 1.10, les valeurs des constantes ont changé pour être uniques.
  235. Si vous utilisiez les constantes comme le manuel le recommande, aucun changement n'est nécessaire.
  236. Mais si vous utilisiez les messages d'erreurs, alors il faudra les changer. Voici les changements
  237. opérés:
  238. </para>
  239. <table id="migration.110.zend.validate.barcodevalidator.table">
  240. <title>Messages de validation disponibles</title>
  241. <tgroup cols="3">
  242. <thead>
  243. <row>
  244. <entry>Validateur</entry>
  245. <entry>Constante</entry>
  246. <entry>Valeur</entry>
  247. </row>
  248. </thead>
  249. <tbody>
  250. <row>
  251. <entry><classname>Alnum</classname></entry>
  252. <entry><constant>STRING_EMPTY</constant></entry>
  253. <entry>alnumStringEmpty</entry>
  254. </row>
  255. <row>
  256. <entry><classname>Alpha</classname></entry>
  257. <entry><constant>STRING_EMPTY</constant></entry>
  258. <entry>alphaStringEmpty</entry>
  259. </row>
  260. <row>
  261. <entry><classname>Barcode_Ean13</classname></entry>
  262. <entry><constant>INVALID</constant></entry>
  263. <entry>ean13Invalid</entry>
  264. </row>
  265. <row>
  266. <entry><classname>Barcode_Ean13</classname></entry>
  267. <entry><constant>INVALID_LENGTH</constant></entry>
  268. <entry>ean13InvalidLength</entry>
  269. </row>
  270. <row>
  271. <entry><classname>Barcode_UpcA</classname></entry>
  272. <entry><constant>INVALID</constant></entry>
  273. <entry>upcaInvalid</entry>
  274. </row>
  275. <row>
  276. <entry><classname>Barcode_UpcA</classname></entry>
  277. <entry><constant>INVALID_LENGTH</constant></entry>
  278. <entry>upcaInvalidLength</entry>
  279. </row>
  280. <row>
  281. <entry><classname>Digits</classname></entry>
  282. <entry><constant>STRING_EMPTY</constant></entry>
  283. <entry>digitsStringEmpty</entry>
  284. </row>
  285. </tbody>
  286. </tgroup>
  287. </table>
  288. </sect3>
  289. </sect2>
  290. </sect1>