migration-19.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="migration.19">
  4. <title>Zend Framework 1.9</title>
  5. <para>
  6. When upgrading from a release of Zend Framework earlier than 1.9.0 to any 1.9 release, you
  7. should note the following migration notes.
  8. </para>
  9. <sect2 id="migration.19.zend.file.transfer">
  10. <title>Zend_File_Transfer</title>
  11. <sect3 id="migration.19.zend.file.transfer.mimetype">
  12. <title>MimeType validation</title>
  13. <para>
  14. For security reasons we had to turn off the default fallback mechanism of the
  15. <classname>MimeType</classname>, <classname>ExcludeMimeType</classname>,
  16. <classname>IsCompressed</classname> and <classname>IsImage</classname> validators.
  17. This means, that if the <emphasis>fileInfo</emphasis> or
  18. <emphasis>magicMime</emphasis> extensions can not be found, the validation will
  19. always fail.
  20. </para>
  21. <para>
  22. If you are in need of validation by using the <acronym>HTTP</acronym> fields which
  23. are provided by the user then you can turn on this feature by using the
  24. <methodname>enableHeaderCheck()</methodname> method.
  25. </para>
  26. <note>
  27. <title>Security hint</title>
  28. <para>
  29. You should note that relying on the <acronym>HTTP</acronym> fields, which are
  30. provided by your user, is a security risk. They can easily be changed and could
  31. allow your user to provide a malcious file.
  32. </para>
  33. </note>
  34. <example id="migration.19.zend.file.transfer.example">
  35. <title>Allow the usage of the HTTP fields</title>
  36. <programlisting language="php"><![CDATA[
  37. // at initiation
  38. $valid = new Zend_File_Transfer_Adapter_Http(array('headerCheck' => true);
  39. // or afterwards
  40. $valid->enableHeaderCheck();
  41. ]]></programlisting>
  42. </example>
  43. </sect3>
  44. </sect2>
  45. <sect2 id="migration.19.zend.filter">
  46. <title>Zend_Filter</title>
  47. <para>
  48. Prior to the 1.9 release, <classname>Zend_Filter</classname> allowed
  49. the usage of the static <methodname>get()</methodname> method. As with
  50. release 1.9 this method has been renamed to
  51. <methodname>filterStatic()</methodname> to be more descriptive. The
  52. old <methodname>get()</methodname> method is marked as deprecated.
  53. </para>
  54. </sect2>
  55. <sect2 id="migration.19.zend.http.client">
  56. <title>Zend_Http_Client</title>
  57. <sect3 id="migration.19.zend.http.client.fileuploadsarray">
  58. <title>Changes to internal uploaded file information storage</title>
  59. <para>
  60. In version 1.9 of Zend Framework, there has been a change in the way
  61. <classname>Zend_Http_Client</classname> internally stores information about
  62. files to be uploaded, set using the
  63. <methodname>Zend_Http_Client::setFileUpload()</methodname> method.
  64. </para>
  65. <para>
  66. This change was introduced in order to allow multiple files to be uploaded
  67. with the same form name, as an array of files. More information about this issue
  68. can be found in <ulink
  69. url="http://framework.zend.com/issues/browse/ZF-5744">this bug report</ulink>.
  70. </para>
  71. <example id="migration.19.zend.http.client.fileuploadsarray.example">
  72. <title>Internal storage of uploaded file information</title>
  73. <programlisting language="php"><![CDATA[
  74. // Upload two files with the same form element name, as an array
  75. $client = new Zend_Http_Client();
  76. $client->setFileUpload('file1.txt',
  77. 'userfile[]',
  78. 'some raw data',
  79. 'text/plain');
  80. $client->setFileUpload('file2.txt',
  81. 'userfile[]',
  82. 'some other data',
  83. 'application/octet-stream');
  84. // In Zend Framework 1.8 or older, the value of
  85. // the protected member $client->files is:
  86. // $client->files = array(
  87. // 'userfile[]' => array('file2.txt',
  88. 'application/octet-stream',
  89. 'some other data')
  90. // );
  91. // In Zend Framework 1.9 or newer, the value of $client->files is:
  92. // $client->files = array(
  93. // array(
  94. // 'formname' => 'userfile[]',
  95. // 'filename' => 'file1.txt,
  96. // 'ctype' => 'text/plain',
  97. // 'data' => 'some raw data'
  98. // ),
  99. // array(
  100. // 'formname' => 'userfile[]',
  101. // 'filename' => 'file2.txt',
  102. // 'formname' => 'application/octet-stream',
  103. // 'formname' => 'some other data'
  104. // )
  105. // );
  106. ]]></programlisting>
  107. </example>
  108. <para>
  109. As you can see, this change permits the usage of the same form element name with
  110. more than one file - however, it introduces a subtle backwards-compatibility change
  111. and as such should be noted.
  112. </para>
  113. </sect3>
  114. <sect3 id="migration.19.zend.http.client.getparamsrecursize">
  115. <title>Deprecation of Zend_Http_Client::_getParametersRecursive()</title>
  116. <para>
  117. Starting from version 1.9, the protected method
  118. <methodname>_getParametersRecursive()</methodname> is no longer used by
  119. <classname>Zend_Http_Client</classname> and is deprecated. Using it will cause an
  120. <constant>E_NOTICE</constant> message to be emitted by <acronym>PHP</acronym>.
  121. </para>
  122. <para>
  123. If you subclass <classname>Zend_Http_Client</classname> and call this method, you
  124. should look into using the
  125. <methodname>Zend_Http_Client::_flattenParametersArray()</methodname> static method
  126. instead.
  127. </para>
  128. <para>
  129. Again, since this <methodname>_getParametersRecursive()</methodname> is a protected
  130. method, this change will only affect users who subclass
  131. <classname>Zend_Http_Client</classname>.
  132. </para>
  133. </sect3>
  134. </sect2>
  135. <sect2 id="migration.19.zend.locale">
  136. <title>Zend_Locale</title>
  137. <sect3 id="migration.19.zend.locale.deprecated">
  138. <title>Deprecated methods</title>
  139. <para>
  140. Some specialized translation methods have been deprecated because they duplicate
  141. existing behaviour. Note that the old methods will still work, but a user notice is
  142. triggered which describes the new call. The methods will be erased with 2.0.
  143. See the following list for old and new method call.
  144. </para>
  145. <table id="migration.19.zend.locale.deprecated.table-1">
  146. <title>List of measurement types</title>
  147. <tgroup cols="2">
  148. <thead>
  149. <row>
  150. <entry>Old call</entry>
  151. <entry>New call</entry>
  152. </row>
  153. </thead>
  154. <tbody>
  155. <row>
  156. <entry>
  157. <methodname>getLanguageTranslationList($locale)</methodname>
  158. </entry>
  159. <entry>
  160. <methodname>getTranslationList('language', $locale)</methodname>
  161. </entry>
  162. </row>
  163. <row>
  164. <entry>
  165. <methodname>getScriptTranslationList($locale)</methodname>
  166. </entry>
  167. <entry>
  168. <methodname>getTranslationList('script', $locale)</methodname>
  169. </entry>
  170. </row>
  171. <row>
  172. <entry>
  173. <methodname>getCountryTranslationList($locale)</methodname>
  174. </entry>
  175. <entry>
  176. <methodname>getTranslationList('territory', $locale, 2)</methodname>
  177. </entry>
  178. </row>
  179. <row>
  180. <entry>
  181. <methodname>getTerritoryTranslationList($locale)</methodname>
  182. </entry>
  183. <entry>
  184. <methodname>getTranslationList('territory', $locale, 1)</methodname>
  185. </entry>
  186. </row>
  187. <row>
  188. <entry>
  189. <methodname>getLanguageTranslation($value, $locale)</methodname>
  190. </entry>
  191. <entry>
  192. <methodname>getTranslation($value, 'language', $locale)</methodname>
  193. </entry>
  194. </row>
  195. <row>
  196. <entry>
  197. <methodname>getScriptTranslation($value, $locale)</methodname>
  198. </entry>
  199. <entry>
  200. <methodname>getTranslation($value, 'script', $locale)</methodname>
  201. </entry>
  202. </row>
  203. <row>
  204. <entry>
  205. <methodname>getCountryTranslation($value, $locale)</methodname>
  206. </entry>
  207. <entry>
  208. <methodname>getTranslation($value, 'country', $locale)</methodname>
  209. </entry>
  210. </row>
  211. <row>
  212. <entry>
  213. <methodname>getTerritoryTranslation($value, $locale)</methodname>
  214. </entry>
  215. <entry>
  216. <methodname>getTranslation($value, 'territory',
  217. $locale)</methodname>
  218. </entry>
  219. </row>
  220. </tbody>
  221. </tgroup>
  222. </table>
  223. </sect3>
  224. </sect2>
  225. <sect2 id="migration.19.zend.view.helper.navigation">
  226. <title>Zend_View_Helper_Navigation</title>
  227. <para>
  228. Prior to the 1.9 release, the menu helper
  229. (<classname>Zend_View_Helper_Navigation_Menu</classname>) did not
  230. render sub menus correctly. When <property>onlyActiveBranch</property>
  231. was <constant>TRUE</constant> and the option <property>renderParents</property>
  232. <constant>FALSE</constant>, nothing would be rendered if the deepest active
  233. page was at a depth lower than the <property>minDepth</property> option.
  234. </para>
  235. <para>
  236. In simpler words; if <property>minDepth</property> was set to '1'
  237. and the active page was at one of the first level pages, nothing
  238. would be rendered, as the following example shows.
  239. </para>
  240. <para>
  241. Consider the following container setup:
  242. </para>
  243. <programlisting language="php"><![CDATA[
  244. <?php
  245. $container = new Zend_Navigation(array(
  246. array(
  247. 'label' => 'Home',
  248. 'uri' => '#'
  249. ),
  250. array(
  251. 'label' => 'Products',
  252. 'uri' => '#',
  253. 'active' => true,
  254. 'pages' => array(
  255. array(
  256. 'label' => 'Server',
  257. 'uri' => '#'
  258. ),
  259. array(
  260. 'label' => 'Studio',
  261. 'uri' => '#'
  262. )
  263. )
  264. ),
  265. array(
  266. 'label' => 'Solutions',
  267. 'uri' => '#'
  268. )
  269. ));
  270. ]]></programlisting>
  271. <para>
  272. The following code is used in a view script:
  273. </para>
  274. <programlisting language="php"><![CDATA[
  275. <?php echo $this->navigation()->menu()->renderMenu($container, array(
  276. 'minDepth' => 1,
  277. 'onlyActiveBranch' => true,
  278. 'renderParents' => false
  279. )); ?>
  280. ]]></programlisting>
  281. <para>
  282. Before release 1.9, the code snippet above would output nothing.
  283. </para>
  284. <para>
  285. Since release 1.9, the <methodname>_renderDeepestMenu()</methodname> method in
  286. <classname>Zend_View_Helper_Navigation_Menu</classname> will accept
  287. active pages at one level below <property>minDepth</property>, as long as
  288. the page has children.
  289. </para>
  290. <para>
  291. The same code snippet will now output the following:
  292. </para>
  293. <programlisting language="html"><![CDATA[
  294. <ul class="navigation">
  295. <li>
  296. <a href="#">Server</a>
  297. </li>
  298. <li>
  299. <a href="#">Studio</a>
  300. </li>
  301. </ul>
  302. ]]></programlisting>
  303. </sect2>
  304. <sect2 id="migration.19.security">
  305. <title>Security fixes as with 1.9.7</title>
  306. <para>
  307. Additionally, users of the 1.9 series may be affected by other changes starting in
  308. version 1.9.7. These are all security fixes that also have potential backwards
  309. compatibility implications.
  310. </para>
  311. <sect3 id="migration.19.security.zend.dojo.editor">
  312. <title>Zend_Dojo_View_Helper_Editor</title>
  313. <para>
  314. A slight change was made in the 1.9 series to modify the default usage of the Editor
  315. dijit to use <acronym>div</acronym> tags instead of a <acronym>textarea</acronym>
  316. tag; the latter usage has <ulink
  317. url="http://api.dojotoolkit.org/jsdoc/HEAD/dijit._editor.RichText">security
  318. implications</ulink>, and usage of <acronym>div</acronym> tags is recommended by the
  319. Dojo project.
  320. </para>
  321. <para>
  322. In order to still allow graceful degradation, a new <varname>degrade</varname>
  323. option was added to the view helper; this would allow developers to optionally use a
  324. <acronym>textarea</acronym> instead. However, this opens applications developed with
  325. that usage to <acronym>XSS</acronym> vectors. In 1.9.7, we have removed this option.
  326. Graceful degradation is still supported, however, via a <acronym>noscript</acronym>
  327. tag that embeds a <acronym>textarea</acronym>. This solution addressess all security
  328. concerns.
  329. </para>
  330. <para>
  331. The takeaway is that if you were using the <varname>degrade</varname> flag, it will
  332. simply be ignored at this time.
  333. </para>
  334. </sect3>
  335. <sect3 id="migration.19.security.zend.filter.html-entities">
  336. <title>Zend_Filter_HtmlEntities</title>
  337. <para>
  338. In order to default to a more secure character encoding,
  339. <classname>Zend_Filter_HtmlEntities</classname> now defaults to
  340. <acronym>UTF-8</acronym> instead of <acronym>ISO-8859-1</acronym>.
  341. </para>
  342. <para>
  343. Additionally, because the actual mechanism is dealing with character encodings and
  344. not character sets, two new methods have been added,
  345. <methodname>setEncoding()</methodname> and <methodname>getEncoding()</methodname>.
  346. The previous methods <methodname>setCharSet()</methodname> and
  347. <methodname>setCharSet()</methodname> are now deprecated and proxy to the new
  348. methods. Finally, instead of using the protected members directly within the
  349. <methodname>filter()</methodname> method, these members are retrieved by their
  350. explicit accessors. If you were extending the filter in the past, please check your
  351. code and unit tests to ensure everything still continues to work.
  352. </para>
  353. </sect3>
  354. <sect3 id="migration.19.security.zend.filter.strip-tags">
  355. <title>Zend_Filter_StripTags</title>
  356. <para>
  357. <classname>Zend_Filter_StripTags</classname> contains a flag,
  358. <varname>commentsAllowed</varname>, that, in previous versions, allowed you to
  359. optionally whitelist <acronym>HTML</acronym> comments in <acronym>HTML</acronym>
  360. text filtered by the class. However, this opens code enabling the flag to
  361. <acronym>XSS</acronym> attacks, particularly in Internet Explorer (which allows
  362. specifying conditional functionality via <acronym>HTML</acronym> comments). Starting
  363. in version 1.9.7 (and backported to versions 1.8.5 and 1.7.9), the
  364. <varname>commentsAllowed</varname> flag no longer has any meaning, and all
  365. <acronym>HTML</acronym> comments, including those containing other
  366. <acronym>HTML</acronym> tags or nested commments, will be stripped from the final
  367. output of the filter.
  368. </para>
  369. </sect3>
  370. </sect2>
  371. </sect1>
  372. <!--
  373. vim:se ts=4 sw=4 et:
  374. -->