migration-110.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 19819 -->
  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.feed.reader">
  12. <title>Zend_Feed_Reader</title>
  13. <para>
  14. With the introduction of Zend Framework 1.10, <classname>Zend_Feed_Reader</classname>'s
  15. handling of retrieving Authors and Contributors was changed, introducing
  16. a break in backwards compatibility. This change was an effort to harmonise
  17. the treatment of such data across the RSS and Atom classes of the component
  18. and enable the return of Author and Contributor data in more accessible,
  19. usable and detailed form. It also rectifies an error in that it was assumed
  20. any author element referred to a name. In RSS this is incorrect as an
  21. author element is actually only required to provide an email address.
  22. In addition, the original implementation applied its RSS limits to Atom
  23. feeds significantly reducing the usefulness of the parser with that format.
  24. </para>
  25. <para>
  26. The change means that methods like <methodname>getAuthors()</methodname>
  27. and <methodname>getContributors</methodname> no longer return a simple array
  28. of strings parsed from the relevant RSS and Atom elements. Instead, the return
  29. value is an <classname>ArrayObject</classname> subclass called
  30. <classname>Zend_Feed_Reader_Collection_Author</classname> which simulates
  31. an iterable multidimensional array of Authors. Each member of this object
  32. will be a simple array with three potential keys (as the source data permits).
  33. These include: name, email and uri.
  34. </para>
  35. <para>
  36. The original behaviour of such methods would have returned a simple
  37. array of strings, each string attempting to present a single name, but
  38. in reality this was unreliable since there is no rule governing the format
  39. of RSS Author strings.
  40. </para>
  41. <para>
  42. The simplest method of simulating the original behaviour of these
  43. methods is to use the <classname>Zend_Feed_Reader_Collection_Author</classname>'s
  44. <methodname>getValues()</methodname> which also returns a simple array of strings
  45. representing the "most relevant data", for authors presumed to be their name.
  46. Each value in the resulting array is derived from the "name" value
  47. attached to each Author (if present). In most cases this simple change is
  48. easy to apply as demonstrated below.
  49. </para>
  50. <programlisting language="php"><![CDATA[
  51. /**
  52. * Before 1.10
  53. */
  54. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  55. $authors = $feed->getAuthors();
  56. /**
  57. * With 1.10
  58. */
  59. $feed = Zend_Feed_Reader::import('http://example.com/feed');
  60. $authors = $feed->getAuthors()->getValues();
  61. ]]></programlisting>
  62. </sect2>
  63. <sect2 id="migration.110.zend.file.transfer">
  64. <title>Zend_File_Transfer</title>
  65. <sect3 id="migration.110.zend.file.transfer.count">
  66. <title>Count 検証</title>
  67. <para>
  68. リリース 1.10 より前は <classname>MimeType</classname> バリデータが誤った命名を使っていました。
  69. 一貫性のために、下記の定数が変更されました。
  70. </para>
  71. <table id="migration.110.zend.file.transfer.count.table">
  72. <title>変更された検証メッセージ</title>
  73. <tgroup cols="4">
  74. <thead>
  75. <row>
  76. <entry>旧</entry>
  77. <entry>新</entry>
  78. <entry>値</entry>
  79. </row>
  80. </thead>
  81. <tbody>
  82. <row>
  83. <entry><constant>TOO_MUCH</constant></entry>
  84. <entry><constant>TOO_MANY</constant></entry>
  85. <entry>
  86. Too many files, maximum '%max%' are allowed but '%count%' are given
  87. </entry>
  88. </row>
  89. <row>
  90. <entry><constant>TOO_LESS</constant></entry>
  91. <entry><constant>TOO_FEW</constant></entry>
  92. <entry>
  93. Too few files, minimum '%min%' are expected but '%count%' are given
  94. </entry>
  95. </row>
  96. </tbody>
  97. </tgroup>
  98. </table>
  99. <para>
  100. コード内でこれらのメッセージを翻訳している場合、新しい定数を使います。
  101. 利点として、正しいつづりを得るために、本来の文字列を翻訳する必要はもうありません。
  102. </para>
  103. </sect3>
  104. </sect2>
  105. <sect2 id="migration.110.zend.translate">
  106. <title>Zend_Translate</title>
  107. <sect3 id="migration.110.zend.translate.xliff">
  108. <title>Xliff アダプタ</title>
  109. <para>
  110. 過去には Xliff アダプタはソースの文字列をメッセージ Id として使いました。
  111. Xliff 標準に沿って、翻訳単位 Id が使われるべきです。
  112. この振る舞いは Zend Framework 1.10 で修正されました。
  113. 今では既定では翻訳単位 Id はメッセージId として使われます。
  114. </para>
  115. <para>
  116. しかし、 <property>useId</property> オプションを <constant>FALSE</constant> に設定することにより、
  117. 正しくなくて古い振る舞いをまだ得られます。
  118. </para>
  119. <programlisting language="php"><![CDATA[
  120. $trans = new Zend_Translate('xliff', '/path/to/source', $locale, array('useId' => false));
  121. ]]></programlisting>
  122. </sect3>
  123. </sect2>
  124. <sect2 id="migration.110.zend.validate">
  125. <title>Zend_Validate</title>
  126. <sect3 id="migration.110.zend.validate.selfwritten">
  127. <title>書かれたバリデータ自身</title>
  128. <para>
  129. かかれたバリデータ自身の内部からエラーを返すよう設定するときは、
  130. <methodname>_error()</methodname>メソッドを呼ばなくてはいけません。
  131. Zend Framework 1.10 以前では、パラメータを与えなくてもこのメソッドを呼び出せました。
  132. そこで、最初に見つかったメッセージテンプレートを使いました。
  133. </para>
  134. <para>
  135. この振る舞いには、一つ以上の異なるメッセージを返すバリデータを使うときに問題があります。
  136. また、既存のバリデータを拡張すると、予期しない結果を得ることもあります。
  137. このせいで、あなたが期待した通りではないメッセージにユーザーが遭遇することにもなりました。
  138. </para>
  139. <programlisting language="php"><![CDATA[
  140. My_Validator extends Zend_Validate_Abstract
  141. {
  142. public isValid($value)
  143. {
  144. ...
  145. $this->_error(); // 異なるOS間での予期されない結果
  146. ...
  147. }
  148. }
  149. ]]></programlisting>
  150. <para>
  151. この問題を防ぐために、<methodname>_error()</methodname>メソッドにパラメータを与えないで呼び出すことは、
  152. もはやできなくなります。
  153. </para>
  154. <programlisting language="php"><![CDATA[
  155. My_Validator extends Zend_Validate_Abstract
  156. {
  157. public isValid($value)
  158. {
  159. ...
  160. $this->_error(self::MY_ERROR); // 定義されたエラー、予期されない結果ではありません
  161. ...
  162. }
  163. }
  164. ]]></programlisting>
  165. </sect3>
  166. <sect3 id="migration.110.zend.validate.datevalidator">
  167. <title>日付バリデータの簡略化</title>
  168. <para>
  169. Zend Framework 1.10 以前では、同一の2つのメッセージが、
  170. 日付バリデータ内でスローされていました。
  171. これらは、<constant>NOT_YYYY_MM_DD</constant>と<constant>FALSEFORMAT</constant>でした。
  172. Zend Framework 1.10 現在では、
  173. 与えられた日付が設定されたフォーマットに一致しない場合、
  174. <constant>FALSEFORMAT</constant>メッセージだけが返されます。
  175. </para>
  176. </sect3>
  177. <sect3 id="migration.110.zend.validate.barcodevalidator">
  178. <title>Alpha、Alnum及びBarcodeバリデータの修正</title>
  179. <para>
  180. Zend Framework 1.10 以前では、バーコード・アダプタ2種類と、
  181. Alpha 及び Alnum バリデータ内のメッセージが同一でした。
  182. このため、カスタムのメッセージ、翻訳、
  183. またはこれらのバリデータの複数のインスタンスを使うときに問題がありました。
  184. </para>
  185. <para>
  186. Zend Framework 1.10 では、定数値は、一意であるように変更されました。
  187. マニュアルで提案されたように定数を使ったときには、変更がありません。
  188. しかし、コードで定数の内容を使ったときには、
  189. それらを変更しなければなりません。
  190. 下記の表では変更された値を示します。
  191. </para>
  192. <table id="migration.110.zend.validate.barcodevalidator.table">
  193. <title>利用可能なバリデータのメッセージ</title>
  194. <tgroup cols="3">
  195. <thead>
  196. <row>
  197. <entry>バリデータ</entry>
  198. <entry>定数</entry>
  199. <entry>値</entry>
  200. </row>
  201. </thead>
  202. <tbody>
  203. <row>
  204. <entry><classname>Alnum</classname></entry>
  205. <entry><constant>STRING_EMPTY</constant></entry>
  206. <entry>alnumStringEmpty</entry>
  207. </row>
  208. <row>
  209. <entry><classname>Alpha</classname></entry>
  210. <entry><constant>STRING_EMPTY</constant></entry>
  211. <entry>alphaStringEmpty</entry>
  212. </row>
  213. <row>
  214. <entry><classname>Barcode_Ean13</classname></entry>
  215. <entry><constant>INVALID</constant></entry>
  216. <entry>ean13Invalid</entry>
  217. </row>
  218. <row>
  219. <entry><classname>Barcode_Ean13</classname></entry>
  220. <entry><constant>INVALID_LENGTH</constant></entry>
  221. <entry>ean13InvalidLength</entry>
  222. </row>
  223. <row>
  224. <entry><classname>Barcode_UpcA</classname></entry>
  225. <entry><constant>INVALID</constant></entry>
  226. <entry>upcaInvalid</entry>
  227. </row>
  228. <row>
  229. <entry><classname>Barcode_UpcA</classname></entry>
  230. <entry><constant>INVALID_LENGTH</constant></entry>
  231. <entry>upcaInvalidLength</entry>
  232. </row>
  233. <row>
  234. <entry><classname>Digits</classname></entry>
  235. <entry><constant>STRING_EMPTY</constant></entry>
  236. <entry>digitsStringEmpty</entry>
  237. </row>
  238. </tbody>
  239. </tgroup>
  240. </table>
  241. </sect3>
  242. </sect2>
  243. </sect1>
  244. <!--
  245. vim:se ts=4 sw=4 et:
  246. -->