migration-110.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 21825 -->
  4. <sect1 id="migration.110">
  5. <title>Zend Framework 1.10</title>
  6. <para>
  7. 以前のバージョンから Zend Framework 1.10 またはそれ以降に更新する際は、
  8. 下記の移行上の注意点に注意すべきです。
  9. </para>
  10. <sect2 id="migration.110.zend.controller.front">
  11. <title>Zend_Controller_Front</title>
  12. <para>
  13. A wrong behaviour was fixed, when there was no module route and no route
  14. matched the given request. Previously, the router returned an unmodified
  15. request object, so the front controller just displayed the default controller
  16. and action. Since Zend Framework 1.10, the router will correctly as noted
  17. in the router interface, throw an exception if no route matches. The error
  18. plugin will then catch that exception and forward to the error controller.
  19. You can then test for that specific error with the constant
  20. <constant>Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE</constant>:
  21. </para>
  22. <programlisting language="php"><![CDATA[
  23. /**
  24. * Before 1.10
  25. */
  26. public function errorAction()
  27. {
  28. $errors = $this->_getParam('error_handler');
  29. switch ($errors->type) {
  30. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  31. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  32. // ...
  33. /**
  34. * With 1.10
  35. */
  36. public function errorAction()
  37. {
  38. $errors = $this->_getParam('error_handler');
  39. switch ($errors->type) {
  40. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  41. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  42. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  43. // ...
  44. ]]></programlisting>
  45. </sect2>
  46. <sect2 id="migration.110.zend.feed.reader">
  47. <title>Zend_Feed_Reader</title>
  48. <para>
  49. With the introduction of Zend Framework 1.10, <classname>Zend_Feed_Reader</classname>'s
  50. handling of retrieving Authors and Contributors was changed, introducing
  51. a break in backwards compatibility. This change was an effort to harmonise
  52. the treatment of such data across the RSS and Atom classes of the component
  53. and enable the return of Author and Contributor data in more accessible,
  54. usable and detailed form. It also rectifies an error in that it was assumed
  55. any author element referred to a name. In RSS this is incorrect as an
  56. author element is actually only required to provide an email address.
  57. In addition, the original implementation applied its RSS limits to Atom
  58. feeds significantly reducing the usefulness of the parser with that format.
  59. </para>
  60. <para>
  61. The change means that methods like <methodname>getAuthors()</methodname>
  62. and <methodname>getContributors</methodname> no longer return a simple array
  63. of strings parsed from the relevant RSS and Atom elements. Instead, the return
  64. value is an <classname>ArrayObject</classname> subclass called
  65. <classname>Zend_Feed_Reader_Collection_Author</classname> which simulates
  66. an iterable multidimensional array of Authors. Each member of this object
  67. will be a simple array with three potential keys (as the source data permits).
  68. These include: name, email and uri.
  69. </para>
  70. <para>
  71. The original behaviour of such methods would have returned a simple
  72. array of strings, each string attempting to present a single name, but
  73. in reality this was unreliable since there is no rule governing the format
  74. of RSS Author strings.
  75. </para>
  76. <para>
  77. The simplest method of simulating the original behaviour of these
  78. methods is to use the <classname>Zend_Feed_Reader_Collection_Author</classname>'s
  79. <methodname>getValues()</methodname> which also returns a simple array of strings
  80. representing the "most relevant data", for authors presumed to be their name.
  81. Each value in the resulting array is derived from the "name" value
  82. attached to each Author (if present). In most cases this simple change is
  83. easy to apply as demonstrated below.
  84. </para>
  85. <programlisting language="php"><![CDATA[
  86. /**
  87. * Before 1.10
  88. */
  89. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  90. $authors = $feed->getAuthors();
  91. /**
  92. * With 1.10
  93. */
  94. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  95. $authors = $feed->getAuthors()->getValues();
  96. ]]></programlisting>
  97. </sect2>
  98. <sect2 id="migration.110.zend.file.transfer">
  99. <title>Zend_File_Transfer</title>
  100. <sect3 id="migration.110.zend.file.transfer.files">
  101. <title>Security change</title>
  102. <para>
  103. For security reasons <classname>Zend_File_Transfer</classname> does no longer store
  104. the original mimetype and filesize which is given from the requesting client into
  105. its internal storage. Instead the real values will be detected at initiation.
  106. </para>
  107. <para>
  108. Additionally the original values within <varname>$_FILES</varname> will be
  109. overridden within the real values at initiation. This makes also
  110. <varname>$_FILES</varname> secure.
  111. </para>
  112. <para>
  113. When you are in need of the original values you can either store them before
  114. initiating <classname>Zend_File_Transfer</classname> or use the
  115. <property>disableInfos</property> option at initiation. Note that this option is
  116. useless when its given after initiation.
  117. </para>
  118. </sect3>
  119. <sect3 id="migration.110.zend.file.transfer.count">
  120. <title>Count 検証</title>
  121. <para>
  122. リリース 1.10 より前は <classname>MimeType</classname> バリデータが誤った命名を使っていました。
  123. 一貫性のために、下記の定数が変更されました。
  124. </para>
  125. <table id="migration.110.zend.file.transfer.count.table">
  126. <title>変更された検証メッセージ</title>
  127. <tgroup cols="4">
  128. <thead>
  129. <row>
  130. <entry>旧</entry>
  131. <entry>新</entry>
  132. <entry>値</entry>
  133. </row>
  134. </thead>
  135. <tbody>
  136. <row>
  137. <entry><constant>TOO_MUCH</constant></entry>
  138. <entry><constant>TOO_MANY</constant></entry>
  139. <entry>
  140. Too many files, maximum '%max%' are allowed but '%count%' are given
  141. </entry>
  142. </row>
  143. <row>
  144. <entry><constant>TOO_LESS</constant></entry>
  145. <entry><constant>TOO_FEW</constant></entry>
  146. <entry>
  147. Too few files, minimum '%min%' are expected but '%count%' are given
  148. </entry>
  149. </row>
  150. </tbody>
  151. </tgroup>
  152. </table>
  153. <para>
  154. コード内でこれらのメッセージを翻訳している場合、新しい定数を使います。
  155. 利点として、正しいつづりを得るために、本来の文字列を翻訳する必要はもうありません。
  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 アダプタ</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. -->