migration-110.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 19819 -->
  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.count">
  65. <title>Count validation</title>
  66. <para>
  67. Before release 1.10 the <classname>MimeType</classname> validator used a wrong
  68. naming. For consistency the following constants have been changed:
  69. </para>
  70. <table id="migration.110.zend.file.transfer.count.table">
  71. <title>Changed Validation Messages</title>
  72. <tgroup cols="4">
  73. <thead>
  74. <row>
  75. <entry>Old</entry>
  76. <entry>New</entry>
  77. <entry>Value</entry>
  78. </row>
  79. </thead>
  80. <tbody>
  81. <row>
  82. <entry><constant>TOO_MUCH</constant></entry>
  83. <entry><constant>TOO_MANY</constant></entry>
  84. <entry>
  85. Too many files, maximum '%max%' are allowed but '%count%' are given
  86. </entry>
  87. </row>
  88. <row>
  89. <entry><constant>TOO_LESS</constant></entry>
  90. <entry><constant>TOO_FEW</constant></entry>
  91. <entry>
  92. Too few files, minimum '%min%' are expected but '%count%' are given
  93. </entry>
  94. </row>
  95. </tbody>
  96. </tgroup>
  97. </table>
  98. <para>
  99. When you are translating these messages within your code then use the new constants.
  100. As benefit you don't need to translate the original string anymore to get a correct
  101. spelling.
  102. </para>
  103. </sect3>
  104. </sect2>
  105. <sect2 id="migration.110.zend.translate">
  106. <title>Zend_Translate</title>
  107. <sect3 id="migration.110.zend.translate.xliff">
  108. <title>Xliff adapter</title>
  109. <para>
  110. In past the Xliff adapter used the source string as message Id. According to the
  111. Xliff standard the trans-unit Id should be used. This behaviour was corrected with
  112. Zend Framework 1.10. Now the trans-unit Id is used as message Id per default.
  113. </para>
  114. <para>
  115. But you can still get the incorrect and old behaviour by setting the
  116. <property>useId</property> option to <constant>FALSE</constant>.
  117. </para>
  118. <programlisting language="php"><![CDATA[
  119. $trans = new Zend_Translate('xliff', '/path/to/source', $locale, array('useId' => false));
  120. ]]></programlisting>
  121. </sect3>
  122. </sect2>
  123. <sect2 id="migration.110.zend.validate">
  124. <title>Zend_Validate</title>
  125. <sect3 id="migration.110.zend.validate.selfwritten">
  126. <title>Adaptateurs personnels</title>
  127. <para>
  128. Lorsqu'une erreur apparait dans un adaptateur crée de toute pièce,
  129. <methodname>_error()</methodname> doit être appelée. Avant Zend Framework 1.10, il était
  130. possible d'appeler cette méthode sans aucun paramètre. Le premier template de message d'erreur
  131. était alors utilisé.
  132. </para>
  133. <para>
  134. Ce comportement est problématique lorsque vous avez des validateurs retournant plusieurs messages.
  135. Aussi, étendre un validateur peut mener à des comportements inattendus dans une telle situation,
  136. comme par exemple l'apparition du mauvais message d'erreur.
  137. </para>
  138. <programlisting language="php"><![CDATA[
  139. My_Validator extends Zend_Validate_Abstract
  140. {
  141. public isValid($value)
  142. {
  143. ...
  144. $this->_error(); // Résultat inattendu
  145. ...
  146. }
  147. }
  148. ]]></programlisting>
  149. <para>
  150. Pour éviter ces problèmes <methodname>_error()</methodname> doit desormais
  151. prendre obligatoirement un paramètre.
  152. </para>
  153. <programlisting language="php"><![CDATA[
  154. My_Validator extends Zend_Validate_Abstract
  155. {
  156. public isValid($value)
  157. {
  158. ...
  159. $this->_error(self::MY_ERROR); // Ok, erreur définie
  160. ...
  161. }
  162. }
  163. ]]></programlisting>
  164. </sect3>
  165. <sect3 id="migration.110.zend.validate.datevalidator">
  166. <title>Simplification dans le validateur des dates</title>
  167. <para>
  168. Avant Zend Framework 1.10, 2 messages identiques étaient envoyés dans le validateur
  169. des dates. <constant>NOT_YYYY_MM_DD</constant> et
  170. <constant>FALSEFORMAT</constant>. Depuis Zend Framework 1.10, seul
  171. <constant>FALSEFORMAT</constant> sera retourné lorsque la date passée ne correspond pas
  172. au format demandé.
  173. </para>
  174. </sect3>
  175. <sect3 id="migration.110.zend.validate.barcodevalidator">
  176. <title>Corrections dans Alpha, Alnum et Barcode</title>
  177. <para>
  178. Avant Zend Framework 1.10, les messages dans les 2 validateurs barcode, le Alpha
  179. et le Alnum étaient identiques. Des problèmes pouvaient alors faire surface avec des
  180. messages personnalisés, des traducteurs ou des instances multiples des validateurs.
  181. </para>
  182. <para>
  183. Depuis Zend Framework 1.10, les valeurs des constantes ont changé pour être uniques.
  184. Si vous utilisiez les constantes comme le manuel le recommande, aucun changement n'est nécessaire.
  185. Mais si vous utilisiez les messages d'erreurs, alors il faudra les changer. Voici les changements
  186. opérés:
  187. </para>
  188. <table id="migration.110.zend.validate.barcodevalidator.table">
  189. <title>Messages de validation disponibles</title>
  190. <tgroup cols="3">
  191. <thead>
  192. <row>
  193. <entry>Validateur</entry>
  194. <entry>Constante</entry>
  195. <entry>Valeur</entry>
  196. </row>
  197. </thead>
  198. <tbody>
  199. <row>
  200. <entry><classname>Alnum</classname></entry>
  201. <entry><constant>STRING_EMPTY</constant></entry>
  202. <entry>alnumStringEmpty</entry>
  203. </row>
  204. <row>
  205. <entry><classname>Alpha</classname></entry>
  206. <entry><constant>STRING_EMPTY</constant></entry>
  207. <entry>alphaStringEmpty</entry>
  208. </row>
  209. <row>
  210. <entry><classname>Barcode_Ean13</classname></entry>
  211. <entry><constant>INVALID</constant></entry>
  212. <entry>ean13Invalid</entry>
  213. </row>
  214. <row>
  215. <entry><classname>Barcode_Ean13</classname></entry>
  216. <entry><constant>INVALID_LENGTH</constant></entry>
  217. <entry>ean13InvalidLength</entry>
  218. </row>
  219. <row>
  220. <entry><classname>Barcode_UpcA</classname></entry>
  221. <entry><constant>INVALID</constant></entry>
  222. <entry>upcaInvalid</entry>
  223. </row>
  224. <row>
  225. <entry><classname>Barcode_UpcA</classname></entry>
  226. <entry><constant>INVALID_LENGTH</constant></entry>
  227. <entry>upcaInvalidLength</entry>
  228. </row>
  229. <row>
  230. <entry><classname>Digits</classname></entry>
  231. <entry><constant>STRING_EMPTY</constant></entry>
  232. <entry>digitsStringEmpty</entry>
  233. </row>
  234. </tbody>
  235. </tgroup>
  236. </table>
  237. </sect3>
  238. </sect2>
  239. </sect1>