migration-19.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- EN-Revision: 18804 -->
  3. <!-- Reviewed: no -->
  4. <sect1 id="migration.19">
  5. <title>Zend Framework 1.9</title>
  6. <para>
  7. Lors de la migration d'un version précédente vers Zend Framework 1.9 ou plus récent
  8. vous devriez prendre note de ce qui suit.
  9. </para>
  10. <sect2 id="migration.19.zend.file.transfer">
  11. <title>Zend_File_Transfer</title>
  12. <sect3 id="migration.110.zend.file.transfer.mimetype">
  13. <title>MimeType validation</title>
  14. <para>
  15. For security reasons we had to turn off the default fallback mechanism of the
  16. <classname>MimeType</classname>, <classname>ExcludeMimeType</classname>,
  17. <classname>IsCompressed</classname> and <classname>IsImage</classname> validators.
  18. This means, that if the <emphasis>fileInfo</emphasis> or
  19. <emphasis>magicMime</emphasis> extensions can not be found, the validation will
  20. always fail.
  21. </para>
  22. <para>
  23. If you are in need of validation by using the <acronym>HTTP</acronym> fields which
  24. are provided by the user then you can turn on this feature by using the
  25. <methodname>enableHeaderCheck()</methodname> method.
  26. </para>
  27. <note>
  28. <title>Security hint</title>
  29. <para>
  30. You should note that relying on the <acronym>HTTP</acronym> fields, which are
  31. provided by your user, is a security risk. They can easily be changed and could
  32. allow your user to provide a malcious file.
  33. </para>
  34. </note>
  35. <example id="migration.110.zend.file.transfer.example">
  36. <title>Allow the usage of the HTTP fields</title>
  37. <programlisting language="php"><![CDATA[
  38. // at initiation
  39. $valid = new Zend_File_Transfer_Adapter_Http(array('headerCheck' => true);
  40. // or afterwards
  41. $valid->enableHeaderCheck();
  42. ]]></programlisting>
  43. </example>
  44. </sect3>
  45. </sect2>
  46. <sect2 id="migration.19.zend.filter">
  47. <title>Zend_Filter</title>
  48. <para>
  49. Avant la version 1.9, <classname>Zend_Filter</classname> permettait l'utilisation
  50. de la méthode statique <methodname>get()</methodname>. Avec la version 1.9 cette
  51. méthode a été renommée en <methodname>filterStatic()</methodname> afin d'être plus
  52. descriptive. L'ancienne méthode <methodname>get()</methodname> est marquée comme
  53. dépréciée.
  54. </para>
  55. </sect2>
  56. <sect2 id="migration.19.zend.http.client">
  57. <title>Zend_Http_Client</title>
  58. <sect3 id="migration.19.zend.http.client.fileuploadsarray">
  59. <title>Changement dans le stockage interne des fichiers d'upload</title>
  60. <para>
  61. Dans la version 1.9 de Zend Framework, il y a eu un changement dans la manière dont
  62. <classname>Zend_Http_Client</classname> stocke en interne les informations concernant les
  63. fichiers ayant été uploadés, affectés grâce à <methodname>Zend_Http_Client::setFileUpload()</methodname>
  64. </para>
  65. <para>
  66. Ce changement a été mis en place de manière à permettre l'envoi de plusieurs fichiers
  67. avec le même nom dans le formulaire, en tant que tableau de fichiers. Plus d'informations à
  68. ce sujet peuvent être trouvées dans ce
  69. <ulink url="http://framework.zend.com/issues/browse/ZF-5744">rapport de bug</ulink>.
  70. </para>
  71. <example id="migration.19.zend.http.client.fileuploadsarray.example">
  72. <title>Stockage interne des informations sur les fichiers uploadés</title>
  73. <programlisting language="php"><![CDATA[
  74. // Uploade 2 fichiers avec le même nom d'élément de formulaire, en tant que tableau
  75. $client = new Zend_Http_Client();
  76. $client->setFileUpload('file1.txt', 'userfile[]', 'some raw data', 'text/plain');
  77. $client->setFileUpload('file2.txt', 'userfile[]', 'some other data', 'application/octet-stream');
  78. // Dans Zend Framework <=1.8, la valeur de l'attribut protégé $client->files est:
  79. // $client->files = array(
  80. // 'userfile[]' => array('file2.txt', 'application/octet-stream', 'some other data')
  81. // );
  82. // Dans Zend Framework >=1.9, la valeur de $client->files est:
  83. // $client->files = array(
  84. // array(
  85. // 'formname' => 'userfile[]',
  86. // 'filename' => 'file1.txt,
  87. // 'ctype' => 'text/plain',
  88. // 'data' => 'some raw data'
  89. // ),
  90. // array(
  91. // 'formname' => 'userfile[]',
  92. // 'filename' => 'file2.txt',
  93. // 'formname' => 'application/octet-stream',
  94. // 'formname' => 'some other data'
  95. // )
  96. // );
  97. ]]></programlisting>
  98. </example>
  99. <para>
  100. Comme vous le voyez, ce changement permet l'utilisation du même élément de formulaire avec plusieurs
  101. fichiers. Cependant ceci introduit un changement subtile dans l'API interne, il est donc signalé ici.
  102. </para>
  103. </sect3>
  104. <sect3 id="migration.19.zend.http.client.getparamsrecursize">
  105. <title>Deprecation of Zend_Http_Client::_getParametersRecursive()</title>
  106. <para>
  107. Starting from version 1.9, the protected method <methodname>_getParametersRecursive()</methodname>
  108. is no longer used by <classname>Zend_Http_Client</classname> and is deprecated.
  109. Using it will cause an E_NOTICE message to be emitted by <acronym>PHP</acronym>.
  110. </para>
  111. <para>
  112. If you subclass <classname>Zend_Http_Client</classname> and call this method, you
  113. should look into using the <methodname>Zend_Http_Client::_flattenParametersArray()</methodname>
  114. static method instead.
  115. </para>
  116. <para>
  117. Again, since this <classname>_getParametersRecursive</classname> is a protected method,
  118. this change will only affect users who subclass <classname>Zend_Http_Client</classname>.
  119. </para>
  120. </sect3>
  121. </sect2>
  122. <sect2 id="migration.19.zend.locale">
  123. <title>Zend_Locale</title>
  124. <sect3 id="migration.19.zend.locale.depreciated">
  125. <title>Méthodes dépréciées</title>
  126. <para>
  127. Quelques méthodes de traductions spéciales ont été dépréciées car elles dupliquaient
  128. un comportement existant. Notez cependant que les anciens appels vont toujours
  129. fonctionner, mais une notice utilisateur, qui décrira le nouvel appel, sera émise.
  130. Ces méthodes seront effacées en 2.0. Ci-dessous la liste des anciens et nouveaux
  131. appels&#160;:
  132. </para>
  133. <table id="migration.19.zend.locale.depreciated.table-1">
  134. <title>Liste des types de mesures</title>
  135. <tgroup cols="2">
  136. <thead>
  137. <row>
  138. <entry>Ancien appel</entry>
  139. <entry>Nouvel appel</entry>
  140. </row>
  141. </thead>
  142. <tbody>
  143. <row>
  144. <entry>getLanguageTranslationList($locale)</entry>
  145. <entry>getTranslationList('language', $locale)</entry>
  146. </row>
  147. <row>
  148. <entry>getScriptTranslationList($locale)</entry>
  149. <entry>getTranslationList('script', $locale)</entry>
  150. </row>
  151. <row>
  152. <entry>getCountryTranslationList($locale)</entry>
  153. <entry>getTranslationList('territory', $locale, 2)</entry>
  154. </row>
  155. <row>
  156. <entry>getTerritoryTranslationList($locale)</entry>
  157. <entry>getTranslationList('territory', $locale, 1)</entry>
  158. </row>
  159. <row>
  160. <entry>getLanguageTranslation($value, $locale)</entry>
  161. <entry>getTranslation($value, 'language', $locale)</entry>
  162. </row>
  163. <row>
  164. <entry>getScriptTranslation($value, $locale)</entry>
  165. <entry>getTranslation($value, 'script', $locale)</entry>
  166. </row>
  167. <row>
  168. <entry>getCountryTranslation($value, $locale)</entry>
  169. <entry>getTranslation($value, 'country', $locale)</entry>
  170. </row>
  171. <row>
  172. <entry>getTerritoryTranslation($value, $locale)</entry>
  173. <entry>getTranslation($value, 'territory', $locale)</entry>
  174. </row>
  175. </tbody>
  176. </tgroup>
  177. </table>
  178. </sect3>
  179. </sect2>
  180. <sect2 id="migration.19.zend.view.helper.navigation">
  181. <title>Zend_View_Helper_Navigation</title>
  182. <para>
  183. Prior to the 1.9 release, the menu helper
  184. (<classname>Zend_View_Helper_Navigation_Menu</classname>) did not
  185. render sub menus correctly. When the <code>onlyActiveBranch</code>
  186. was <constant>TRUE</constant> and the option <code>renderParents</code>
  187. <constant>FALSE</constant>, nothing would be rendered if the deepest active
  188. page was at a depth lower than the <code>minDepth</code> option.
  189. </para>
  190. <para>
  191. In simpler words; if <code>minDepth</code> was set to <code>1</code>
  192. and the active page was at one of the first level pages, nothing
  193. would be rendered, as the following example shows.
  194. </para>
  195. <para>
  196. Consider the following container setup:
  197. </para>
  198. <programlisting language="php"><![CDATA[
  199. $container = new Zend_Navigation(array(
  200. array(
  201. 'label' => 'Home',
  202. 'uri' => '#'
  203. ),
  204. array(
  205. 'label' => 'Products',
  206. 'uri' => '#',
  207. 'active' => true,
  208. 'pages' => array(
  209. array(
  210. 'label' => 'Server',
  211. 'uri' => '#'
  212. ),
  213. array(
  214. 'label' => 'Studio',
  215. 'uri' => '#'
  216. )
  217. )
  218. ),
  219. array(
  220. 'label' => 'Solutions',
  221. 'uri' => '#'
  222. )
  223. ));
  224. ]]></programlisting>
  225. <para>
  226. The following code is used in a view script:
  227. </para>
  228. <programlisting language="php"><![CDATA[
  229. echo $this->navigation()->menu()->renderMenu($container, array(
  230. 'minDepth' => 1,
  231. 'onlyActiveBranch' => true,
  232. 'renderParents' => false
  233. ));
  234. ]]></programlisting>
  235. <para>
  236. Before release 1.9, the code snippet above would output nothing.
  237. </para>
  238. <para>
  239. Since release 1.9, the <methodname>_renderDeepestMenu()</methodname> method in
  240. <classname>Zend_View_Helper_Navigation_Menu</classname> will accept
  241. active pages at one level below <code>minDepth</code>, as long as
  242. the page has children.
  243. </para>
  244. <para>
  245. The same code snippet will now output the following:
  246. </para>
  247. <programlisting language="html"><![CDATA[
  248. <ul class="navigation">
  249. <li>
  250. <a href="#">Server</a>
  251. </li>
  252. <li>
  253. <a href="#">Studio</a>
  254. </li>
  255. </ul>
  256. ]]></programlisting>
  257. </sect2>
  258. </sect1>