migration-110.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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.controller.front">
  10. <title>Zend_Controller_Front</title>
  11. <para>
  12. A wrong behaviour was fixed, when there was no module route and no route
  13. matched the given request. Previously, the router returned an unmodified
  14. request object, so the front controller just displayed the default controller
  15. and action. Since Zend Framework 1.10, the router will correctly as noted
  16. in the router interface, throw an exception if no route matches. The error
  17. plugin will then catch that exception and forward to the error controller.
  18. You can then test for that specific error with the constant
  19. <constant>Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE</constant>:
  20. </para>
  21. <programlisting language="php"><![CDATA[
  22. /**
  23. * Before 1.10
  24. */
  25. public function errorAction()
  26. {
  27. $errors = $this->_getParam('error_handler');
  28. switch ($errors->type) {
  29. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  30. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  31. // ...
  32. /**
  33. * With 1.10
  34. */
  35. public function errorAction()
  36. {
  37. $errors = $this->_getParam('error_handler');
  38. switch ($errors->type) {
  39. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  40. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  41. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  42. // ...
  43. ]]></programlisting>
  44. </sect2>
  45. <sect2 id="migration.110.zend.feed.reader">
  46. <title>Zend_Feed_Reader</title>
  47. <para>
  48. With the introduction of Zend Framework 1.10, <classname>Zend_Feed_Reader</classname>'s
  49. handling of retrieving Authors and Contributors was changed, introducing
  50. a break in backwards compatibility. This change was an effort to harmonise
  51. the treatment of such data across the RSS and Atom classes of the component
  52. and enable the return of Author and Contributor data in more accessible,
  53. usable and detailed form. It also rectifies an error in that it was assumed
  54. any author element referred to a name. In RSS this is incorrect as an
  55. author element is actually only required to provide an email address.
  56. In addition, the original implementation applied its RSS limits to Atom
  57. feeds significantly reducing the usefulness of the parser with that format.
  58. </para>
  59. <para>
  60. The change means that methods like <methodname>getAuthors()</methodname>
  61. and <methodname>getContributors</methodname> no longer return a simple array
  62. of strings parsed from the relevant RSS and Atom elements. Instead, the return
  63. value is an <classname>ArrayObject</classname> subclass called
  64. <classname>Zend_Feed_Reader_Collection_Author</classname> which simulates
  65. an iterable multidimensional array of Authors. Each member of this object
  66. will be a simple array with three potential keys (as the source data permits).
  67. These include: name, email and uri.
  68. </para>
  69. <para>
  70. The original behaviour of such methods would have returned a simple
  71. array of strings, each string attempting to present a single name, but
  72. in reality this was unreliable since there is no rule governing the format
  73. of RSS Author strings.
  74. </para>
  75. <para>
  76. The simplest method of simulating the original behaviour of these
  77. methods is to use the <classname>Zend_Feed_Reader_Collection_Author</classname>'s
  78. <methodname>getValues()</methodname> which also returns a simple array of strings
  79. representing the "most relevant data", for authors presumed to be their name.
  80. Each value in the resulting array is derived from the "name" value
  81. attached to each Author (if present). In most cases this simple change is
  82. easy to apply as demonstrated below.
  83. </para>
  84. <programlisting language="php"><![CDATA[
  85. /**
  86. * Before 1.10
  87. */
  88. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  89. $authors = $feed->getAuthors();
  90. /**
  91. * With 1.10
  92. */
  93. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  94. $authors = $feed->getAuthors()->getValues();
  95. ]]></programlisting>
  96. </sect2>
  97. <sect2 id="migration.110.zend.file.transfer">
  98. <title>Zend_File_Transfer</title>
  99. <sect3 id="migration.110.zend.file.transfer.files">
  100. <title>Security change</title>
  101. <para>
  102. For security reasons <classname>Zend_File_Transfer</classname> does no longer store
  103. the original mimetype and filesize which is given from the requesting client into
  104. its internal storage. Instead the real values will be detected at initiation.
  105. </para>
  106. <para>
  107. Additionally the original values within <varname>$_FILES</varname> will be
  108. overridden within the real values at initiation. This makes also
  109. <varname>$_FILES</varname> secure.
  110. </para>
  111. <para>
  112. When you are in need of the original values you can either store them before
  113. initiating <classname>Zend_File_Transfer</classname> or use the
  114. <property>disableInfos</property> option at initiation. Note that this option is
  115. useless when its given after initiation.
  116. </para>
  117. </sect3>
  118. <sect3 id="migration.110.zend.file.transfer.count">
  119. <title>Count validation</title>
  120. <para>
  121. Before release 1.10 the <classname>MimeType</classname> validator used a wrong
  122. naming. For consistency the following constants have been changed:
  123. </para>
  124. <table id="migration.110.zend.file.transfer.count.table">
  125. <title>Changed Validation Messages</title>
  126. <tgroup cols="4">
  127. <thead>
  128. <row>
  129. <entry>Old</entry>
  130. <entry>New</entry>
  131. <entry>Value</entry>
  132. </row>
  133. </thead>
  134. <tbody>
  135. <row>
  136. <entry><constant>TOO_MUCH</constant></entry>
  137. <entry><constant>TOO_MANY</constant></entry>
  138. <entry>
  139. Too many files, maximum '%max%' are allowed but '%count%' are given
  140. </entry>
  141. </row>
  142. <row>
  143. <entry><constant>TOO_LESS</constant></entry>
  144. <entry><constant>TOO_FEW</constant></entry>
  145. <entry>
  146. Too few files, minimum '%min%' are expected but '%count%' are given
  147. </entry>
  148. </row>
  149. </tbody>
  150. </tgroup>
  151. </table>
  152. <para>
  153. When you are translating these messages within your code then use the new constants.
  154. As benefit you don't need to translate the original string anymore to get a correct
  155. spelling.
  156. </para>
  157. </sect3>
  158. </sect2>
  159. <sect2 id="migration.110.zend.filter.html-entities">
  160. <title>Zend_Filter_HtmlEntities</title>
  161. <para>
  162. In order to default to a more secure character encoding,
  163. <classname>Zend_Filter_HtmlEntities</classname> now defaults to <acronym>UTF-8</acronym>
  164. instead of <acronym>ISO-8859-1</acronym>.
  165. </para>
  166. <para>
  167. Additionally, because the actual mechanism is dealing with character encodings and not
  168. character sets, two new methods have been added, <methodname>setEncoding()</methodname>
  169. and <methodname>getEncoding()</methodname>. The previous methods
  170. <methodname>setCharSet()</methodname> and <methodname>setCharSet()</methodname> are now
  171. deprecated and proxy to the new methods. Finally, instead of using the protected members
  172. directly within the <methodname>filter()</methodname> method, these members are
  173. retrieved by their explicit accessors. If you were extending the filter in the past,
  174. please check your code and unit tests to ensure everything still continues to work.
  175. </para>
  176. </sect2>
  177. <sect2 id="migration.110.zend.filter.strip-tags">
  178. <title>Zend_Filter_StripTags</title>
  179. <para>
  180. <classname>Zend_Filter_StripTags</classname> contains a flag,
  181. <varname>commentsAllowed</varname>, that, in previous versions, allowed you to
  182. optionally whitelist <acronym>HTML</acronym> comments in <acronym>HTML</acronym> text
  183. filtered by the class. However, this opens code enabling the flag to
  184. <acronym>XSS</acronym> attacks, particularly in Internet Explorer (which allows
  185. specifying conditional functionality via <acronym>HTML</acronym> comments). Starting
  186. in version 1.9.7 (and backported to versions 1.8.5 and 1.7.9), the
  187. <varname>commentsAllowed</varname> flag no longer has any meaning, and all
  188. <acronym>HTML</acronym> comments, including those containing other
  189. <acronym>HTML</acronym> tags or nested commments, will be stripped from the final output
  190. of the filter.
  191. </para>
  192. </sect2>
  193. <sect2 id="migration.110.zend.translate">
  194. <title>Zend_Translate</title>
  195. <sect3 id="migration.110.zend.translate.xliff">
  196. <title>Xliff adapter</title>
  197. <para>
  198. In past the Xliff adapter used the source string as message Id. According to the
  199. Xliff standard the trans-unit Id should be used. This behaviour was corrected with
  200. Zend Framework 1.10. Now the trans-unit Id is used as message Id per default.
  201. </para>
  202. <para>
  203. But you can still get the incorrect and old behaviour by setting the
  204. <property>useId</property> option to <constant>FALSE</constant>.
  205. </para>
  206. <programlisting language="php"><![CDATA[
  207. $trans = new Zend_Translate(
  208. 'xliff', '/path/to/source', $locale, array('useId' => false)
  209. );
  210. ]]></programlisting>
  211. </sect3>
  212. </sect2>
  213. <sect2 id="migration.110.zend.validate">
  214. <title>Zend_Validate</title>
  215. <sect3 id="migration.110.zend.validate.selfwritten">
  216. <title>Self written validators</title>
  217. <para>
  218. When setting returning a error from within a self written validator you have to
  219. call the <methodname>_error()</methodname> method. Before Zend Framework 1.10 you
  220. were able to call this method without giving a parameter. It used then the first
  221. found message template.
  222. </para>
  223. <para>
  224. This behaviour is problematic when you have validators with more than one different
  225. message to be returned. Also when you extend an existing validator you can get
  226. unexpected results. This could lead to the problem that your user get not the
  227. message you expected.
  228. </para>
  229. <programlisting language="php"><![CDATA[
  230. My_Validator extends Zend_Validate_Abstract
  231. {
  232. public isValid($value)
  233. {
  234. ...
  235. $this->_error(); // unexpected results between different OS
  236. ...
  237. }
  238. }
  239. ]]></programlisting>
  240. <para>
  241. To prevent this problem the <methodname>_error()</methodname> method is no longer
  242. allowed to be called without giving a parameter.
  243. </para>
  244. <programlisting language="php"><![CDATA[
  245. My_Validator extends Zend_Validate_Abstract
  246. {
  247. public isValid($value)
  248. {
  249. ...
  250. $this->_error(self::MY_ERROR); // defined error, no unexpected results
  251. ...
  252. }
  253. }
  254. ]]></programlisting>
  255. </sect3>
  256. <sect3 id="migration.110.zend.validate.datevalidator">
  257. <title>Simplification in date validator</title>
  258. <para>
  259. Before Zend Framework 1.10 2 identical messages were thrown within the date
  260. validator. These were <constant>NOT_YYYY_MM_DD</constant> and
  261. <constant>FALSEFORMAT</constant>. As of Zend Framework 1.10 only the
  262. <constant>FALSEFORMAT</constant> message will be returned when the given date
  263. does not match the set format.
  264. </para>
  265. </sect3>
  266. <sect3 id="migration.110.zend.validate.barcodevalidator">
  267. <title>Fixes in Alpha, Alnum and Barcode validator</title>
  268. <para>
  269. Before Zend Framework 1.10 the messages within the 2 barcode adapters, the Alpha
  270. and the Alnum validator were identical. This introduced problems when using custom
  271. messages, translations or multiple instances of these validators.
  272. </para>
  273. <para>
  274. As with Zend Framework 1.10 the values of the constants were changed to
  275. be unique. When you used the constants as proposed in the manual there is
  276. no change for you. But when you used the content of the constants in your code
  277. then you will have to change them. The following table shows you the changed values:
  278. </para>
  279. <table id="migration.110.zend.validate.barcodevalidator.table">
  280. <title>Available Validation Messages</title>
  281. <tgroup cols="3">
  282. <thead>
  283. <row>
  284. <entry>Validator</entry>
  285. <entry>Constant</entry>
  286. <entry>Value</entry>
  287. </row>
  288. </thead>
  289. <tbody>
  290. <row>
  291. <entry><classname>Alnum</classname></entry>
  292. <entry><constant>STRING_EMPTY</constant></entry>
  293. <entry>alnumStringEmpty</entry>
  294. </row>
  295. <row>
  296. <entry><classname>Alpha</classname></entry>
  297. <entry><constant>STRING_EMPTY</constant></entry>
  298. <entry>alphaStringEmpty</entry>
  299. </row>
  300. <row>
  301. <entry><classname>Barcode_Ean13</classname></entry>
  302. <entry><constant>INVALID</constant></entry>
  303. <entry>ean13Invalid</entry>
  304. </row>
  305. <row>
  306. <entry><classname>Barcode_Ean13</classname></entry>
  307. <entry><constant>INVALID_LENGTH</constant></entry>
  308. <entry>ean13InvalidLength</entry>
  309. </row>
  310. <row>
  311. <entry><classname>Barcode_UpcA</classname></entry>
  312. <entry><constant>INVALID</constant></entry>
  313. <entry>upcaInvalid</entry>
  314. </row>
  315. <row>
  316. <entry><classname>Barcode_UpcA</classname></entry>
  317. <entry><constant>INVALID_LENGTH</constant></entry>
  318. <entry>upcaInvalidLength</entry>
  319. </row>
  320. <row>
  321. <entry><classname>Digits</classname></entry>
  322. <entry><constant>STRING_EMPTY</constant></entry>
  323. <entry>digitsStringEmpty</entry>
  324. </row>
  325. </tbody>
  326. </tgroup>
  327. </table>
  328. </sect3>
  329. </sect2>
  330. </sect1>
  331. <!--
  332. vim:se ts=4 sw=4 et:
  333. -->