migration-110.xml 18 KB

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