migration-110.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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.filter.html-entities">
  105. <title>Zend_Filter_HtmlEntities</title>
  106. <para>
  107. In order to default to a more secure character encoding,
  108. <classname>Zend_Filter_HtmlEntities</classname> now defaults to <acronym>UTF-8</acronym>
  109. instead of <acronym>ISO-8859-1</acronym>.
  110. </para>
  111. <para>
  112. Additionally, because the actual mechanism is dealing with character encodings and not
  113. character sets, two new methods have been added, <methodname>setEncoding()</methodname>
  114. and <methodname>getEncoding()</methodname>. The previous methods
  115. <methodname>setCharSet()</methodname> and <methodname>setCharSet()</methodname> are now
  116. deprecated and proxy to the new methods. Finally, instead of using the protected members
  117. directly within the <methodname>filter()</methodname> method, these members are
  118. retrieved by their explicit accessors. If you were extending the filter in the past,
  119. please check your code and unit tests to ensure everything still continues to work.
  120. </para>
  121. </sect2>
  122. <sect2 id="migration.110.zend.filter.strip-tags">
  123. <title>Zend_Filter_StripTags</title>
  124. <para>
  125. <classname>Zend_Filter_StripTags</classname> contains a flag,
  126. <varname>commentsAllowed</varname>, that, in previous versions, allowed you to
  127. optionally whitelist HTML comments in HTML text filtered by the class. However, this
  128. opens code enabling the flag to <acronym>XSS</acronym> attacks, particularly in Internet
  129. Explorer (which allows specifying conditional functionality via HTML comments). Starting
  130. in version 1.9.7 (and backported to versions 1.8.5 and 1.7.9), the
  131. <varname>commentsAllowed</varname> flag no longer has any meaning, and all HTML
  132. comments, including those containing other HTML tags or nested commments, will be
  133. stripped from the final output of the filter.
  134. </para>
  135. </sect2>
  136. <sect2 id="migration.110.zend.translate">
  137. <title>Zend_Translate</title>
  138. <sect3 id="migration.110.zend.translate.xliff">
  139. <title>Xliff adapter</title>
  140. <para>
  141. In past the Xliff adapter used the source string as message Id. According to the
  142. Xliff standard the trans-unit Id should be used. This behaviour was corrected with
  143. Zend Framework 1.10. Now the trans-unit Id is used as message Id per default.
  144. </para>
  145. <para>
  146. But you can still get the incorrect and old behaviour by setting the
  147. <property>useId</property> option to <constant>FALSE</constant>.
  148. </para>
  149. <programlisting language="php"><![CDATA[
  150. $trans = new Zend_Translate('xliff', '/path/to/source', $locale, array('useId' => false));
  151. ]]></programlisting>
  152. </sect3>
  153. </sect2>
  154. <sect2 id="migration.110.zend.validate">
  155. <title>Zend_Validate</title>
  156. <sect3 id="migration.110.zend.validate.selfwritten">
  157. <title>Self written validators</title>
  158. <para>
  159. When setting returning a error from within a self written validator you have to
  160. call the <methodname>_error()</methodname> method. Before Zend Framework 1.10 you
  161. were able to call this method without giving a parameter. It used then the first
  162. found message template.
  163. </para>
  164. <para>
  165. This behaviour is problematic when you have validators with more than one different
  166. message to be returned. Also when you extend an existing validator you can get
  167. unexpected results. This could lead to the problem that your user get not the
  168. message you expected.
  169. </para>
  170. <programlisting language="php"><![CDATA[
  171. My_Validator extends Zend_Validate_Abstract
  172. {
  173. public isValid($value)
  174. {
  175. ...
  176. $this->_error(); // unexpected results between different OS
  177. ...
  178. }
  179. }
  180. ]]></programlisting>
  181. <para>
  182. To prevent this problem the <methodname>_error()</methodname> method is no longer
  183. allowed to be called without giving a parameter.
  184. </para>
  185. <programlisting language="php"><![CDATA[
  186. My_Validator extends Zend_Validate_Abstract
  187. {
  188. public isValid($value)
  189. {
  190. ...
  191. $this->_error(self::MY_ERROR); // defined error, no unexpected results
  192. ...
  193. }
  194. }
  195. ]]></programlisting>
  196. </sect3>
  197. <sect3 id="migration.110.zend.validate.datevalidator">
  198. <title>Simplification in date validator</title>
  199. <para>
  200. Before Zend Framework 1.10 2 identical messages were thrown within the date
  201. validator. These were <constant>NOT_YYYY_MM_DD</constant> and
  202. <constant>FALSEFORMAT</constant>. As of Zend Framework 1.10 only the
  203. <constant>FALSEFORMAT</constant> message will be returned when the given date
  204. does not match the set format.
  205. </para>
  206. </sect3>
  207. <sect3 id="migration.110.zend.validate.barcodevalidator">
  208. <title>Fixes in Alpha, Alnum and Barcode validator</title>
  209. <para>
  210. Before Zend Framework 1.10 the messages within the 2 barcode adapters, the Alpha
  211. and the Alnum validator were identical. This introduced problems when using custom
  212. messages, translations or multiple instances of these validators.
  213. </para>
  214. <para>
  215. As with Zend Framework 1.10 the values of the constants were changed to
  216. be unique. When you used the constants as proposed in the manual there is
  217. no change for you. But when you used the content of the constants in your code
  218. then you will have to change them. The following table shows you the changed values:
  219. </para>
  220. <table id="migration.110.zend.validate.barcodevalidator.table">
  221. <title>Available Validation Messages</title>
  222. <tgroup cols="3">
  223. <thead>
  224. <row>
  225. <entry>Validator</entry>
  226. <entry>Constant</entry>
  227. <entry>Value</entry>
  228. </row>
  229. </thead>
  230. <tbody>
  231. <row>
  232. <entry><classname>Alnum</classname></entry>
  233. <entry><constant>STRING_EMPTY</constant></entry>
  234. <entry>alnumStringEmpty</entry>
  235. </row>
  236. <row>
  237. <entry><classname>Alpha</classname></entry>
  238. <entry><constant>STRING_EMPTY</constant></entry>
  239. <entry>alphaStringEmpty</entry>
  240. </row>
  241. <row>
  242. <entry><classname>Barcode_Ean13</classname></entry>
  243. <entry><constant>INVALID</constant></entry>
  244. <entry>ean13Invalid</entry>
  245. </row>
  246. <row>
  247. <entry><classname>Barcode_Ean13</classname></entry>
  248. <entry><constant>INVALID_LENGTH</constant></entry>
  249. <entry>ean13InvalidLength</entry>
  250. </row>
  251. <row>
  252. <entry><classname>Barcode_UpcA</classname></entry>
  253. <entry><constant>INVALID</constant></entry>
  254. <entry>upcaInvalid</entry>
  255. </row>
  256. <row>
  257. <entry><classname>Barcode_UpcA</classname></entry>
  258. <entry><constant>INVALID_LENGTH</constant></entry>
  259. <entry>upcaInvalidLength</entry>
  260. </row>
  261. <row>
  262. <entry><classname>Digits</classname></entry>
  263. <entry><constant>STRING_EMPTY</constant></entry>
  264. <entry>digitsStringEmpty</entry>
  265. </row>
  266. </tbody>
  267. </tgroup>
  268. </table>
  269. </sect3>
  270. </sect2>
  271. </sect1>
  272. <!--
  273. vim:se ts=4 sw=4 et:
  274. -->