migration-110.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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.files">
  64. <title>Security change</title>
  65. <para>
  66. For security reasons <classname>Zend_File_Transfer</classname> does no longer store
  67. the original mimetype and filesize which is given from the requesting client into
  68. its internal storage. Instead the real values will be detected at initiation.
  69. </para>
  70. <para>
  71. Additionally the original values within <varname>$_FILES</varname> will be
  72. overridden within the real values at initiation. This makes also
  73. <varname>$_FILES</varname> secure.
  74. </para>
  75. <para>
  76. When you are in need of the original values you can eighter store them before
  77. initiating <classname>Zend_File_Transfer</classname> or use the
  78. <property>disableInfos</property> option at initiation. Note that this option is
  79. useless when its given after initiation.
  80. </para>
  81. </sect3>
  82. <sect3 id="migration.110.zend.file.transfer.count">
  83. <title>Count validation</title>
  84. <para>
  85. Before release 1.10 the <classname>MimeType</classname> validator used a wrong
  86. naming. For consistency the following constants have been changed:
  87. </para>
  88. <table id="migration.110.zend.file.transfer.count.table">
  89. <title>Changed Validation Messages</title>
  90. <tgroup cols="4">
  91. <thead>
  92. <row>
  93. <entry>Old</entry>
  94. <entry>New</entry>
  95. <entry>Value</entry>
  96. </row>
  97. </thead>
  98. <tbody>
  99. <row>
  100. <entry><constant>TOO_MUCH</constant></entry>
  101. <entry><constant>TOO_MANY</constant></entry>
  102. <entry>
  103. Too many files, maximum '%max%' are allowed but '%count%' are given
  104. </entry>
  105. </row>
  106. <row>
  107. <entry><constant>TOO_LESS</constant></entry>
  108. <entry><constant>TOO_FEW</constant></entry>
  109. <entry>
  110. Too few files, minimum '%min%' are expected but '%count%' are given
  111. </entry>
  112. </row>
  113. </tbody>
  114. </tgroup>
  115. </table>
  116. <para>
  117. When you are translating these messages within your code then use the new constants.
  118. As benefit you don't need to translate the original string anymore to get a correct
  119. spelling.
  120. </para>
  121. </sect3>
  122. </sect2>
  123. <sect2 id="migration.110.zend.filter.html-entities">
  124. <title>Zend_Filter_HtmlEntities</title>
  125. <para>
  126. In order to default to a more secure character encoding,
  127. <classname>Zend_Filter_HtmlEntities</classname> now defaults to <acronym>UTF-8</acronym>
  128. instead of <acronym>ISO-8859-1</acronym>.
  129. </para>
  130. <para>
  131. Additionally, because the actual mechanism is dealing with character encodings and not
  132. character sets, two new methods have been added, <methodname>setEncoding()</methodname>
  133. and <methodname>getEncoding()</methodname>. The previous methods
  134. <methodname>setCharSet()</methodname> and <methodname>setCharSet()</methodname> are now
  135. deprecated and proxy to the new methods. Finally, instead of using the protected members
  136. directly within the <methodname>filter()</methodname> method, these members are
  137. retrieved by their explicit accessors. If you were extending the filter in the past,
  138. please check your code and unit tests to ensure everything still continues to work.
  139. </para>
  140. </sect2>
  141. <sect2 id="migration.110.zend.filter.strip-tags">
  142. <title>Zend_Filter_StripTags</title>
  143. <para>
  144. <classname>Zend_Filter_StripTags</classname> contains a flag,
  145. <varname>commentsAllowed</varname>, that, in previous versions, allowed you to
  146. optionally whitelist HTML comments in HTML text filtered by the class. However, this
  147. opens code enabling the flag to <acronym>XSS</acronym> attacks, particularly in Internet
  148. Explorer (which allows specifying conditional functionality via HTML comments). Starting
  149. in version 1.9.7 (and backported to versions 1.8.5 and 1.7.9), the
  150. <varname>commentsAllowed</varname> flag no longer has any meaning, and all HTML
  151. comments, including those containing other HTML tags or nested commments, will be
  152. stripped from the final output of the filter.
  153. </para>
  154. </sect2>
  155. <sect2 id="migration.110.zend.translate">
  156. <title>Zend_Translate</title>
  157. <sect3 id="migration.110.zend.translate.xliff">
  158. <title>Xliff adapter</title>
  159. <para>
  160. In past the Xliff adapter used the source string as message Id. According to the
  161. Xliff standard the trans-unit Id should be used. This behaviour was corrected with
  162. Zend Framework 1.10. Now the trans-unit Id is used as message Id per default.
  163. </para>
  164. <para>
  165. But you can still get the incorrect and old behaviour by setting the
  166. <property>useId</property> option to <constant>FALSE</constant>.
  167. </para>
  168. <programlisting language="php"><![CDATA[
  169. $trans = new Zend_Translate('xliff', '/path/to/source', $locale, array('useId' => false));
  170. ]]></programlisting>
  171. </sect3>
  172. </sect2>
  173. <sect2 id="migration.110.zend.validate">
  174. <title>Zend_Validate</title>
  175. <sect3 id="migration.110.zend.validate.selfwritten">
  176. <title>Self written validators</title>
  177. <para>
  178. When setting returning a error from within a self written validator you have to
  179. call the <methodname>_error()</methodname> method. Before Zend Framework 1.10 you
  180. were able to call this method without giving a parameter. It used then the first
  181. found message template.
  182. </para>
  183. <para>
  184. This behaviour is problematic when you have validators with more than one different
  185. message to be returned. Also when you extend an existing validator you can get
  186. unexpected results. This could lead to the problem that your user get not the
  187. message you expected.
  188. </para>
  189. <programlisting language="php"><![CDATA[
  190. My_Validator extends Zend_Validate_Abstract
  191. {
  192. public isValid($value)
  193. {
  194. ...
  195. $this->_error(); // unexpected results between different OS
  196. ...
  197. }
  198. }
  199. ]]></programlisting>
  200. <para>
  201. To prevent this problem the <methodname>_error()</methodname> method is no longer
  202. allowed to be called without giving a parameter.
  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); // defined error, no unexpected results
  211. ...
  212. }
  213. }
  214. ]]></programlisting>
  215. </sect3>
  216. <sect3 id="migration.110.zend.validate.datevalidator">
  217. <title>Simplification in date validator</title>
  218. <para>
  219. Before Zend Framework 1.10 2 identical messages were thrown within the date
  220. validator. These were <constant>NOT_YYYY_MM_DD</constant> and
  221. <constant>FALSEFORMAT</constant>. As of Zend Framework 1.10 only the
  222. <constant>FALSEFORMAT</constant> message will be returned when the given date
  223. does not match the set format.
  224. </para>
  225. </sect3>
  226. <sect3 id="migration.110.zend.validate.barcodevalidator">
  227. <title>Fixes in Alpha, Alnum and Barcode validator</title>
  228. <para>
  229. Before Zend Framework 1.10 the messages within the 2 barcode adapters, the Alpha
  230. and the Alnum validator were identical. This introduced problems when using custom
  231. messages, translations or multiple instances of these validators.
  232. </para>
  233. <para>
  234. As with Zend Framework 1.10 the values of the constants were changed to
  235. be unique. When you used the constants as proposed in the manual there is
  236. no change for you. But when you used the content of the constants in your code
  237. then you will have to change them. The following table shows you the changed values:
  238. </para>
  239. <table id="migration.110.zend.validate.barcodevalidator.table">
  240. <title>Available Validation Messages</title>
  241. <tgroup cols="3">
  242. <thead>
  243. <row>
  244. <entry>Validator</entry>
  245. <entry>Constant</entry>
  246. <entry>Value</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>
  291. <!--
  292. vim:se ts=4 sw=4 et:
  293. -->