migration-110.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="migration.110">
  4. <title>Zend Framework 1.10</title>
  5. <para>
  6. When upgrading from a previous release to Zend Framework 1.10 or higher you
  7. should note the following migration notes.
  8. </para>
  9. <sect2 id="migration.110.zend.feed.reader">
  10. <title>Zend_Feed_Reader</title>
  11. <para>
  12. With the introduction of Zend Framework 1.10, <classname>Zend_Feed_Reader</classname>'s
  13. handling of retrieving Authors and Contributors was changed, introducing
  14. a break in backwards compatibility. This change was an effort to harmonise
  15. the treatment of such data across the RSS and Atom classes of the component
  16. and enable the return of Author and Contributor data in more accessible,
  17. usable and detailed form. It also rectifies an error in that it was assumed
  18. any author element referred to a name. In RSS this is incorrect as an
  19. author element is actually only required to provide an email address.
  20. In addition, the original implementation applied its RSS limits to Atom
  21. feeds significantly reducing the usefulness of the parser with that format.
  22. </para>
  23. <para>
  24. The change means that methods like <methodname>getAuthors()</methodname>
  25. and <methodname>getContributors</methodname> no longer return a simple array
  26. of strings parsed from the relevant RSS and Atom elements. Instead, the return
  27. value is an <classname>ArrayObject</classname> subclass called
  28. <classname>Zend_Feed_Reader_Collection_Author</classname> which simulates
  29. an iterable multidimensional array of Authors. Each member of this object
  30. will be a simple array with three potential keys (as the source data permits).
  31. These include: name, email and uri.
  32. </para>
  33. <para>
  34. The original behaviour of such methods would have returned a simple
  35. array of strings, each string attempting to present a single name, but
  36. in reality this was unreliable since there is no rule governing the format
  37. of RSS Author strings.
  38. </para>
  39. <para>
  40. The simplest method of simulating the original behaviour of these
  41. methods is to use the <classname>Zend_Feed_Reader_Collection_Author</classname>'s
  42. <methodname>getValues()</methodname> which also returns a simple array of strings
  43. representing the "most relevant data", for authors presumed to be their name.
  44. Each value in the resulting array is derived from the "name" value
  45. attached to each Author (if present). In most cases this simple change is
  46. easy to apply as demonstrated below.
  47. </para>
  48. <programlisting language="php"><![CDATA[
  49. /**
  50. * Before 1.10
  51. */
  52. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  53. $authors = $feed->getAuthors();
  54. /**
  55. * With 1.10
  56. */
  57. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  58. $authors = $feed->getAuthors()->getValues();
  59. ]]></programlisting>
  60. </sect2>
  61. <sect2 id="migration.110.zend.file.transfer">
  62. <title>Zend_File_Transfer</title>
  63. <sect3 id="migration.110.zend.file.transfer.count">
  64. <title>Count validation</title>
  65. <para>
  66. Before release 1.10 the <classname>MimeType</classname> validator used a wrong
  67. naming. For consistency the following constants have been changed:
  68. </para>
  69. <table id="migration.110.zend.file.transfer.count.table">
  70. <title>Changed Validation Messages</title>
  71. <tgroup cols="4">
  72. <thead>
  73. <row>
  74. <entry>Old</entry>
  75. <entry>New</entry>
  76. <entry>Value</entry>
  77. </row>
  78. </thead>
  79. <tbody>
  80. <row>
  81. <entry><constant>TOO_MUCH</constant></entry>
  82. <entry><constant>TOO_MANY</constant></entry>
  83. <entry>
  84. Too many files, maximum '%max%' are allowed but '%count%' are given
  85. </entry>
  86. </row>
  87. <row>
  88. <entry><constant>TOO_LESS</constant></entry>
  89. <entry><constant>TOO_FEW</constant></entry>
  90. <entry>
  91. Too few files, minimum '%min%' are expected but '%count%' are given
  92. </entry>
  93. </row>
  94. </tbody>
  95. </tgroup>
  96. </table>
  97. <para>
  98. When you are translating these messages within your code then use the new constants.
  99. As benefit you don't need to translate the original string anymore to get a correct
  100. spelling.
  101. </para>
  102. </sect3>
  103. </sect2>
  104. <sect2 id="migration.110.zend.translate">
  105. <title>Zend_Translate</title>
  106. <sect3 id="migration.110.zend.translate.xliff">
  107. <title>Xliff adapter</title>
  108. <para>
  109. In past the Xliff adapter used the source string as message Id. According to the
  110. Xliff standard the trans-unit Id should be used. This behaviour was corrected with
  111. Zend Framework 1.10. Now the trans-unit Id is used as message Id per default.
  112. </para>
  113. <para>
  114. But you can still get the incorrect and old behaviour by setting the
  115. <property>useId</property> option to <constant>FALSE</constant>.
  116. </para>
  117. <programlisting language="php"><![CDATA[
  118. $trans = new Zend_Translate('xliff', '/path/to/source', $locale, array('useId' => false));
  119. ]]></programlisting>
  120. </sect3>
  121. </sect2>
  122. <sect2 id="migration.110.zend.validate">
  123. <title>Zend_Validate</title>
  124. <sect3 id="migration.110.zend.validate.selfwritten">
  125. <title>Self written validators</title>
  126. <para>
  127. When setting returning a error from within a self written validator you have to
  128. call the <methodname>_error()</methodname> method. Before Zend Framework 1.10 you
  129. were able to call this method without giving a parameter. It used then the first
  130. found message template.
  131. </para>
  132. <para>
  133. This behaviour is problematic when you have validators with more than one different
  134. message to be returned. Also when you extend an existing validator you can get
  135. unexpected results. This could lead to the problem that your user get not the
  136. message you expected.
  137. </para>
  138. <programlisting language="php"><![CDATA[
  139. My_Validator extends Zend_Validate_Abstract
  140. {
  141. public isValid($value)
  142. {
  143. ...
  144. $this->_error(); // unexpected results between different OS
  145. ...
  146. }
  147. }
  148. ]]></programlisting>
  149. <para>
  150. To prevent this problem the <methodname>_error()</methodname> method is no longer
  151. allowed to be called without giving a parameter.
  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); // defined error, no unexpected results
  160. ...
  161. }
  162. }
  163. ]]></programlisting>
  164. </sect3>
  165. <sect3 id="migration.110.zend.validate.datevalidator">
  166. <title>Simplification in date validator</title>
  167. <para>
  168. Before Zend Framework 1.10 2 identical messages were thrown within the date
  169. validator. These were <constant>NOT_YYYY_MM_DD</constant> and
  170. <constant>FALSEFORMAT</constant>. As of Zend Framework 1.10 only the
  171. <constant>FALSEFORMAT</constant> message will be returned when the given date
  172. does not match the set format.
  173. </para>
  174. </sect3>
  175. <sect3 id="migration.110.zend.validate.barcodevalidator">
  176. <title>Fixes in Alpha, Alnum and Barcode validator</title>
  177. <para>
  178. Before Zend Framework 1.10 the messages within the 2 barcode adapters, the Alpha
  179. and the Alnum validator were identical. This introduced problems when using custom
  180. messages, translations or multiple instances of these validators.
  181. </para>
  182. <para>
  183. As with Zend Framework 1.10 the values of the constants were changed to
  184. be unique. When you used the constants as proposed in the manual there is
  185. no change for you. But when you used the content of the constants in your code
  186. then you will have to change them. The following table shows you the changed values:
  187. </para>
  188. <table id="migration.110.zend.validate.barcodevalidator.table">
  189. <title>Available Validation Messages</title>
  190. <tgroup cols="3">
  191. <thead>
  192. <row>
  193. <entry>Validator</entry>
  194. <entry>Constant</entry>
  195. <entry>Value</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>
  240. <!--
  241. vim:se ts=4 sw=4 et:
  242. -->