migration-110.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 21661 -->
  4. <sect1 id="migration.110">
  5. <title>Zend Framework 1.10</title>
  6. <para>
  7. 以前のバージョンから Zend Framework 1.10 またはそれ以降に更新する際は、
  8. 下記の移行上の注意点に注意すべきです。
  9. </para>
  10. <!-- TODO : to be translated -->
  11. <sect2 id="migration.110.zend.controller.front">
  12. <title>Zend_Controller_Front</title>
  13. <para>
  14. A wrong behaviour was fixed, when there was no module route and no route
  15. matched the given request. Previously, the router returned an unmodified
  16. request object, so the front controller just displayed the default controller
  17. and action. Since Zend Framework 1.10, the router will correctly as noted
  18. in the router interface, throw an exception if no route matches. The error
  19. plugin will then catch that exception and forward to the error controller.
  20. You can then test for that specific error with the constant
  21. <constant>Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE</constant>:
  22. </para>
  23. <programlisting language="php"><![CDATA[
  24. /**
  25. * Before 1.10
  26. */
  27. public function errorAction()
  28. {
  29. $errors = $this->_getParam('error_handler');
  30. switch ($errors->type) {
  31. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  32. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  33. // ...
  34. /**
  35. * With 1.10
  36. */
  37. public function errorAction()
  38. {
  39. $errors = $this->_getParam('error_handler');
  40. switch ($errors->type) {
  41. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  42. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  43. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  44. // ...
  45. ]]></programlisting>
  46. </sect2>
  47. <sect2 id="migration.110.zend.feed.reader">
  48. <title>Zend_Feed_Reader</title>
  49. <para>
  50. With the introduction of Zend Framework 1.10, <classname>Zend_Feed_Reader</classname>'s
  51. handling of retrieving Authors and Contributors was changed, introducing
  52. a break in backwards compatibility. This change was an effort to harmonise
  53. the treatment of such data across the RSS and Atom classes of the component
  54. and enable the return of Author and Contributor data in more accessible,
  55. usable and detailed form. It also rectifies an error in that it was assumed
  56. any author element referred to a name. In RSS this is incorrect as an
  57. author element is actually only required to provide an email address.
  58. In addition, the original implementation applied its RSS limits to Atom
  59. feeds significantly reducing the usefulness of the parser with that format.
  60. </para>
  61. <para>
  62. The change means that methods like <methodname>getAuthors()</methodname>
  63. and <methodname>getContributors</methodname> no longer return a simple array
  64. of strings parsed from the relevant RSS and Atom elements. Instead, the return
  65. value is an <classname>ArrayObject</classname> subclass called
  66. <classname>Zend_Feed_Reader_Collection_Author</classname> which simulates
  67. an iterable multidimensional array of Authors. Each member of this object
  68. will be a simple array with three potential keys (as the source data permits).
  69. These include: name, email and uri.
  70. </para>
  71. <para>
  72. The original behaviour of such methods would have returned a simple
  73. array of strings, each string attempting to present a single name, but
  74. in reality this was unreliable since there is no rule governing the format
  75. of RSS Author strings.
  76. </para>
  77. <para>
  78. The simplest method of simulating the original behaviour of these
  79. methods is to use the <classname>Zend_Feed_Reader_Collection_Author</classname>'s
  80. <methodname>getValues()</methodname> which also returns a simple array of strings
  81. representing the "most relevant data", for authors presumed to be their name.
  82. Each value in the resulting array is derived from the "name" value
  83. attached to each Author (if present). In most cases this simple change is
  84. easy to apply as demonstrated below.
  85. </para>
  86. <programlisting language="php"><![CDATA[
  87. /**
  88. * Before 1.10
  89. */
  90. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  91. $authors = $feed->getAuthors();
  92. /**
  93. * With 1.10
  94. */
  95. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  96. $authors = $feed->getAuthors()->getValues();
  97. ]]></programlisting>
  98. </sect2>
  99. <sect2 id="migration.110.zend.file.transfer">
  100. <title>Zend_File_Transfer</title>
  101. <sect3 id="migration.110.zend.file.transfer.files">
  102. <title>Security change</title>
  103. <para>
  104. For security reasons <classname>Zend_File_Transfer</classname> does no longer store
  105. the original mimetype and filesize which is given from the requesting client into
  106. its internal storage. Instead the real values will be detected at initiation.
  107. </para>
  108. <para>
  109. Additionally the original values within <varname>$_FILES</varname> will be
  110. overridden within the real values at initiation. This makes also
  111. <varname>$_FILES</varname> secure.
  112. </para>
  113. <para>
  114. When you are in need of the original values you can either store them before
  115. initiating <classname>Zend_File_Transfer</classname> or use the
  116. <property>disableInfos</property> option at initiation. Note that this option is
  117. useless when its given after initiation.
  118. </para>
  119. </sect3>
  120. <sect3 id="migration.110.zend.file.transfer.count">
  121. <title>Count 検証</title>
  122. <para>
  123. リリース 1.10 より前は <classname>MimeType</classname> バリデータが誤った命名を使っていました。
  124. 一貫性のために、下記の定数が変更されました。
  125. </para>
  126. <table id="migration.110.zend.file.transfer.count.table">
  127. <title>変更された検証メッセージ</title>
  128. <tgroup cols="4">
  129. <thead>
  130. <row>
  131. <entry>旧</entry>
  132. <entry>新</entry>
  133. <entry>値</entry>
  134. </row>
  135. </thead>
  136. <tbody>
  137. <row>
  138. <entry><constant>TOO_MUCH</constant></entry>
  139. <entry><constant>TOO_MANY</constant></entry>
  140. <entry>
  141. Too many files, maximum '%max%' are allowed but '%count%' are given
  142. </entry>
  143. </row>
  144. <row>
  145. <entry><constant>TOO_LESS</constant></entry>
  146. <entry><constant>TOO_FEW</constant></entry>
  147. <entry>
  148. Too few files, minimum '%min%' are expected but '%count%' are given
  149. </entry>
  150. </row>
  151. </tbody>
  152. </tgroup>
  153. </table>
  154. <para>
  155. コード内でこれらのメッセージを翻訳している場合、新しい定数を使います。
  156. 利点として、正しいつづりを得るために、本来の文字列を翻訳する必要はもうありません。
  157. </para>
  158. </sect3>
  159. </sect2>
  160. <!-- TODO : to be translated -->
  161. <sect2 id="migration.110.zend.filter.html-entities">
  162. <title>Zend_Filter_HtmlEntities</title>
  163. <para>
  164. In order to default to a more secure character encoding,
  165. <classname>Zend_Filter_HtmlEntities</classname> now defaults to <acronym>UTF-8</acronym>
  166. instead of <acronym>ISO-8859-1</acronym>.
  167. </para>
  168. <para>
  169. Additionally, because the actual mechanism is dealing with character encodings and not
  170. character sets, two new methods have been added, <methodname>setEncoding()</methodname>
  171. and <methodname>getEncoding()</methodname>. The previous methods
  172. <methodname>setCharSet()</methodname> and <methodname>setCharSet()</methodname> are now
  173. deprecated and proxy to the new methods. Finally, instead of using the protected members
  174. directly within the <methodname>filter()</methodname> method, these members are
  175. retrieved by their explicit accessors. If you were extending the filter in the past,
  176. please check your code and unit tests to ensure everything still continues to work.
  177. </para>
  178. </sect2>
  179. <sect2 id="migration.110.zend.filter.strip-tags">
  180. <title>Zend_Filter_StripTags</title>
  181. <para>
  182. <classname>Zend_Filter_StripTags</classname> contains a flag,
  183. <varname>commentsAllowed</varname>, that, in previous versions, allowed you to
  184. optionally whitelist HTML comments in HTML text filtered by the class. However, this
  185. opens code enabling the flag to <acronym>XSS</acronym> attacks, particularly in Internet
  186. Explorer (which allows specifying conditional functionality via HTML comments). Starting
  187. in version 1.9.7 (and backported to versions 1.8.5 and 1.7.9), the
  188. <varname>commentsAllowed</varname> flag no longer has any meaning, and all HTML
  189. comments, including those containing other HTML tags or nested commments, will be
  190. stripped from the final output 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 アダプタ</title>
  197. <para>
  198. 過去には Xliff アダプタはソースの文字列をメッセージ Id として使いました。
  199. Xliff 標準に沿って、翻訳単位 Id が使われるべきです。
  200. この振る舞いは Zend Framework 1.10 で修正されました。
  201. 今では既定では翻訳単位 Id はメッセージId として使われます。
  202. </para>
  203. <para>
  204. しかし、 <property>useId</property> オプションを <constant>FALSE</constant> に設定することにより、
  205. 正しくなくて古い振る舞いをまだ得られます。
  206. </para>
  207. <programlisting language="php"><![CDATA[
  208. $trans = new Zend_Translate(
  209. 'xliff', '/path/to/source', $locale, array('useId' => false)
  210. );
  211. ]]></programlisting>
  212. </sect3>
  213. </sect2>
  214. <sect2 id="migration.110.zend.validate">
  215. <title>Zend_Validate</title>
  216. <sect3 id="migration.110.zend.validate.selfwritten">
  217. <title>書かれたバリデータ自身</title>
  218. <para>
  219. かかれたバリデータ自身の内部からエラーを返すよう設定するときは、
  220. <methodname>_error()</methodname>メソッドを呼ばなくてはいけません。
  221. Zend Framework 1.10 以前では、パラメータを与えなくてもこのメソッドを呼び出せました。
  222. そこで、最初に見つかったメッセージテンプレートを使いました。
  223. </para>
  224. <para>
  225. この振る舞いには、一つ以上の異なるメッセージを返すバリデータを使うときに問題があります。
  226. また、既存のバリデータを拡張すると、予期しない結果を得ることもあります。
  227. このせいで、あなたが期待した通りではないメッセージにユーザーが遭遇することにもなりました。
  228. </para>
  229. <programlisting language="php"><![CDATA[
  230. My_Validator extends Zend_Validate_Abstract
  231. {
  232. public isValid($value)
  233. {
  234. ...
  235. $this->_error(); // 異なるOS間での予期されない結果
  236. ...
  237. }
  238. }
  239. ]]></programlisting>
  240. <para>
  241. この問題を防ぐために、<methodname>_error()</methodname>メソッドにパラメータを与えないで呼び出すことは、
  242. もはやできなくなります。
  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); // 定義されたエラー、予期されない結果ではありません
  251. ...
  252. }
  253. }
  254. ]]></programlisting>
  255. </sect3>
  256. <sect3 id="migration.110.zend.validate.datevalidator">
  257. <title>日付バリデータの簡略化</title>
  258. <para>
  259. Zend Framework 1.10 以前では、同一の2つのメッセージが、
  260. 日付バリデータ内でスローされていました。
  261. これらは、<constant>NOT_YYYY_MM_DD</constant>と<constant>FALSEFORMAT</constant>でした。
  262. Zend Framework 1.10 現在では、
  263. 与えられた日付が設定されたフォーマットに一致しない場合、
  264. <constant>FALSEFORMAT</constant>メッセージだけが返されます。
  265. </para>
  266. </sect3>
  267. <sect3 id="migration.110.zend.validate.barcodevalidator">
  268. <title>Alpha、Alnum及びBarcodeバリデータの修正</title>
  269. <para>
  270. Zend Framework 1.10 以前では、バーコード・アダプタ2種類と、
  271. Alpha 及び Alnum バリデータ内のメッセージが同一でした。
  272. このため、カスタムのメッセージ、翻訳、
  273. またはこれらのバリデータの複数のインスタンスを使うときに問題がありました。
  274. </para>
  275. <para>
  276. Zend Framework 1.10 では、定数値は、一意であるように変更されました。
  277. マニュアルで提案されたように定数を使ったときには、変更がありません。
  278. しかし、コードで定数の内容を使ったときには、
  279. それらを変更しなければなりません。
  280. 下記の表では変更された値を示します。
  281. </para>
  282. <table id="migration.110.zend.validate.barcodevalidator.table">
  283. <title>利用可能なバリデータのメッセージ</title>
  284. <tgroup cols="3">
  285. <thead>
  286. <row>
  287. <entry>バリデータ</entry>
  288. <entry>定数</entry>
  289. <entry>値</entry>
  290. </row>
  291. </thead>
  292. <tbody>
  293. <row>
  294. <entry><classname>Alnum</classname></entry>
  295. <entry><constant>STRING_EMPTY</constant></entry>
  296. <entry>alnumStringEmpty</entry>
  297. </row>
  298. <row>
  299. <entry><classname>Alpha</classname></entry>
  300. <entry><constant>STRING_EMPTY</constant></entry>
  301. <entry>alphaStringEmpty</entry>
  302. </row>
  303. <row>
  304. <entry><classname>Barcode_Ean13</classname></entry>
  305. <entry><constant>INVALID</constant></entry>
  306. <entry>ean13Invalid</entry>
  307. </row>
  308. <row>
  309. <entry><classname>Barcode_Ean13</classname></entry>
  310. <entry><constant>INVALID_LENGTH</constant></entry>
  311. <entry>ean13InvalidLength</entry>
  312. </row>
  313. <row>
  314. <entry><classname>Barcode_UpcA</classname></entry>
  315. <entry><constant>INVALID</constant></entry>
  316. <entry>upcaInvalid</entry>
  317. </row>
  318. <row>
  319. <entry><classname>Barcode_UpcA</classname></entry>
  320. <entry><constant>INVALID_LENGTH</constant></entry>
  321. <entry>upcaInvalidLength</entry>
  322. </row>
  323. <row>
  324. <entry><classname>Digits</classname></entry>
  325. <entry><constant>STRING_EMPTY</constant></entry>
  326. <entry>digitsStringEmpty</entry>
  327. </row>
  328. </tbody>
  329. </tgroup>
  330. </table>
  331. </sect3>
  332. </sect2>
  333. </sect1>
  334. <!--
  335. vim:se ts=4 sw=4 et:
  336. -->