| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect1 id="migration.110">
- <title>Zend Framework 1.10</title>
- <para>
- When upgrading from a previous release to Zend Framework 1.10 or higher you
- should note the following migration notes.
- </para>
- <sect2 id="migration.110.zend.controller.front">
- <title>Zend_Controller_Front</title>
- <para>
- A wrong behaviour was fixed, when there was no module route and no route
- matched the given request. Previously, the router returned an unmodified
- request object, so the front controller just displayed the default controller
- and action. Since Zend Framework 1.10, the router will correctly as noted
- in the router interface, throw an exception if no route matches. The error
- plugin will then catch that exception and forward to the error controller.
- You can then test for that specific error with the constant
- <constant>Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE</constant>:
- </para>
- <programlisting language="php"><![CDATA[
- /**
- * Before 1.10
- */
- public function errorAction()
- {
- $errors = $this->_getParam('error_handler');
- switch ($errors->type) {
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
- // ...
- /**
- * With 1.10
- */
- public function errorAction()
- {
- $errors = $this->_getParam('error_handler');
- switch ($errors->type) {
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
- // ...
- ]]></programlisting>
- </sect2>
- <sect2 id="migration.110.zend.feed.reader">
- <title>Zend_Feed_Reader</title>
- <para>
- With the introduction of Zend Framework 1.10, <classname>Zend_Feed_Reader</classname>'s
- handling of retrieving Authors and Contributors was changed, introducing
- a break in backwards compatibility. This change was an effort to harmonise
- the treatment of such data across the RSS and Atom classes of the component
- and enable the return of Author and Contributor data in more accessible,
- usable and detailed form. It also rectifies an error in that it was assumed
- any author element referred to a name. In RSS this is incorrect as an
- author element is actually only required to provide an email address.
- In addition, the original implementation applied its RSS limits to Atom
- feeds significantly reducing the usefulness of the parser with that format.
- </para>
- <para>
- The change means that methods like <methodname>getAuthors()</methodname>
- and <methodname>getContributors</methodname> no longer return a simple array
- of strings parsed from the relevant RSS and Atom elements. Instead, the return
- value is an <classname>ArrayObject</classname> subclass called
- <classname>Zend_Feed_Reader_Collection_Author</classname> which simulates
- an iterable multidimensional array of Authors. Each member of this object
- will be a simple array with three potential keys (as the source data permits).
- These include: name, email and uri.
- </para>
- <para>
- The original behaviour of such methods would have returned a simple
- array of strings, each string attempting to present a single name, but
- in reality this was unreliable since there is no rule governing the format
- of RSS Author strings.
- </para>
- <para>
- The simplest method of simulating the original behaviour of these
- methods is to use the <classname>Zend_Feed_Reader_Collection_Author</classname>'s
- <methodname>getValues()</methodname> which also returns a simple array of strings
- representing the "most relevant data", for authors presumed to be their name.
- Each value in the resulting array is derived from the "name" value
- attached to each Author (if present). In most cases this simple change is
- easy to apply as demonstrated below.
- </para>
- <programlisting language="php"><![CDATA[
- /**
- * Before 1.10
- */
- $feed = Zend_Feed_Reader::import('http://example.com/feed');
- $authors = $feed->getAuthors();
- /**
- * With 1.10
- */
- $feed = Zend_Feed_Reader::import('http://example.com/feed');
- $authors = $feed->getAuthors()->getValues();
- ]]></programlisting>
- </sect2>
- <sect2 id="migration.110.zend.file.transfer">
- <title>Zend_File_Transfer</title>
- <sect3 id="migration.110.zend.file.transfer.files">
- <title>Security change</title>
- <para>
- For security reasons <classname>Zend_File_Transfer</classname> does no longer store
- the original mimetype and filesize which is given from the requesting client into
- its internal storage. Instead the real values will be detected at initiation.
- </para>
- <para>
- Additionally the original values within <varname>$_FILES</varname> will be
- overridden within the real values at initiation. This makes also
- <varname>$_FILES</varname> secure.
- </para>
- <para>
- When you are in need of the original values you can either store them before
- initiating <classname>Zend_File_Transfer</classname> or use the
- <property>disableInfos</property> option at initiation. Note that this option is
- useless when its given after initiation.
- </para>
- </sect3>
- <sect3 id="migration.110.zend.file.transfer.count">
- <title>Count validation</title>
- <para>
- Before release 1.10 the <classname>MimeType</classname> validator used a wrong
- naming. For consistency the following constants have been changed:
- </para>
- <table id="migration.110.zend.file.transfer.count.table">
- <title>Changed Validation Messages</title>
- <tgroup cols="4">
- <thead>
- <row>
- <entry>Old</entry>
- <entry>New</entry>
- <entry>Value</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><constant>TOO_MUCH</constant></entry>
- <entry><constant>TOO_MANY</constant></entry>
- <entry>
- Too many files, maximum '%max%' are allowed but '%count%' are given
- </entry>
- </row>
- <row>
- <entry><constant>TOO_LESS</constant></entry>
- <entry><constant>TOO_FEW</constant></entry>
- <entry>
- Too few files, minimum '%min%' are expected but '%count%' are given
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>
- When you are translating these messages within your code then use the new constants.
- As benefit you don't need to translate the original string anymore to get a correct
- spelling.
- </para>
- </sect3>
- </sect2>
- <sect2 id="migration.110.zend.filter.html-entities">
- <title>Zend_Filter_HtmlEntities</title>
- <para>
- In order to default to a more secure character encoding,
- <classname>Zend_Filter_HtmlEntities</classname> now defaults to <acronym>UTF-8</acronym>
- instead of <acronym>ISO-8859-1</acronym>.
- </para>
- <para>
- Additionally, because the actual mechanism is dealing with character encodings and not
- character sets, two new methods have been added, <methodname>setEncoding()</methodname>
- and <methodname>getEncoding()</methodname>. The previous methods
- <methodname>setCharSet()</methodname> and <methodname>setCharSet()</methodname> are now
- deprecated and proxy to the new methods. Finally, instead of using the protected members
- directly within the <methodname>filter()</methodname> method, these members are
- retrieved by their explicit accessors. If you were extending the filter in the past,
- please check your code and unit tests to ensure everything still continues to work.
- </para>
- </sect2>
- <sect2 id="migration.110.zend.filter.strip-tags">
- <title>Zend_Filter_StripTags</title>
- <para>
- <classname>Zend_Filter_StripTags</classname> contains a flag,
- <varname>commentsAllowed</varname>, that, in previous versions, allowed you to
- optionally whitelist <acronym>HTML</acronym> comments in <acronym>HTML</acronym> text
- filtered by the class. However, this opens code enabling the flag to
- <acronym>XSS</acronym> attacks, particularly in Internet Explorer (which allows
- specifying conditional functionality via <acronym>HTML</acronym> comments). Starting
- in version 1.9.7 (and backported to versions 1.8.5 and 1.7.9), the
- <varname>commentsAllowed</varname> flag no longer has any meaning, and all
- <acronym>HTML</acronym> comments, including those containing other
- <acronym>HTML</acronym> tags or nested commments, will be stripped from the final output
- of the filter.
- </para>
- </sect2>
- <sect2 id="migration.110.zend.translate">
- <title>Zend_Translate</title>
- <sect3 id="migration.110.zend.translate.xliff">
- <title>Xliff adapter</title>
- <para>
- In past the Xliff adapter used the source string as message Id. According to the
- Xliff standard the trans-unit Id should be used. This behaviour was corrected with
- Zend Framework 1.10. Now the trans-unit Id is used as message Id per default.
- </para>
- <para>
- But you can still get the incorrect and old behaviour by setting the
- <property>useId</property> option to <constant>FALSE</constant>.
- </para>
- <programlisting language="php"><![CDATA[
- $trans = new Zend_Translate(
- 'xliff', '/path/to/source', $locale, array('useId' => false)
- );
- ]]></programlisting>
- </sect3>
- </sect2>
- <sect2 id="migration.110.zend.validate">
- <title>Zend_Validate</title>
- <sect3 id="migration.110.zend.validate.selfwritten">
- <title>Self written validators</title>
- <para>
- When setting returning a error from within a self written validator you have to
- call the <methodname>_error()</methodname> method. Before Zend Framework 1.10 you
- were able to call this method without giving a parameter. It used then the first
- found message template.
- </para>
- <para>
- This behaviour is problematic when you have validators with more than one different
- message to be returned. Also when you extend an existing validator you can get
- unexpected results. This could lead to the problem that your user get not the
- message you expected.
- </para>
- <programlisting language="php"><![CDATA[
- My_Validator extends Zend_Validate_Abstract
- {
- public isValid($value)
- {
- ...
- $this->_error(); // unexpected results between different OS
- ...
- }
- }
- ]]></programlisting>
- <para>
- To prevent this problem the <methodname>_error()</methodname> method is no longer
- allowed to be called without giving a parameter.
- </para>
- <programlisting language="php"><![CDATA[
- My_Validator extends Zend_Validate_Abstract
- {
- public isValid($value)
- {
- ...
- $this->_error(self::MY_ERROR); // defined error, no unexpected results
- ...
- }
- }
- ]]></programlisting>
- </sect3>
- <sect3 id="migration.110.zend.validate.datevalidator">
- <title>Simplification in date validator</title>
- <para>
- Before Zend Framework 1.10 2 identical messages were thrown within the date
- validator. These were <constant>NOT_YYYY_MM_DD</constant> and
- <constant>FALSEFORMAT</constant>. As of Zend Framework 1.10 only the
- <constant>FALSEFORMAT</constant> message will be returned when the given date
- does not match the set format.
- </para>
- </sect3>
- <sect3 id="migration.110.zend.validate.barcodevalidator">
- <title>Fixes in Alpha, Alnum and Barcode validator</title>
- <para>
- Before Zend Framework 1.10 the messages within the 2 barcode adapters, the Alpha
- and the Alnum validator were identical. This introduced problems when using custom
- messages, translations or multiple instances of these validators.
- </para>
- <para>
- As with Zend Framework 1.10 the values of the constants were changed to
- be unique. When you used the constants as proposed in the manual there is
- no change for you. But when you used the content of the constants in your code
- then you will have to change them. The following table shows you the changed values:
- </para>
- <table id="migration.110.zend.validate.barcodevalidator.table">
- <title>Available Validation Messages</title>
- <tgroup cols="3">
- <thead>
- <row>
- <entry>Validator</entry>
- <entry>Constant</entry>
- <entry>Value</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><classname>Alnum</classname></entry>
- <entry><constant>STRING_EMPTY</constant></entry>
- <entry>alnumStringEmpty</entry>
- </row>
- <row>
- <entry><classname>Alpha</classname></entry>
- <entry><constant>STRING_EMPTY</constant></entry>
- <entry>alphaStringEmpty</entry>
- </row>
- <row>
- <entry><classname>Barcode_Ean13</classname></entry>
- <entry><constant>INVALID</constant></entry>
- <entry>ean13Invalid</entry>
- </row>
- <row>
- <entry><classname>Barcode_Ean13</classname></entry>
- <entry><constant>INVALID_LENGTH</constant></entry>
- <entry>ean13InvalidLength</entry>
- </row>
- <row>
- <entry><classname>Barcode_UpcA</classname></entry>
- <entry><constant>INVALID</constant></entry>
- <entry>upcaInvalid</entry>
- </row>
- <row>
- <entry><classname>Barcode_UpcA</classname></entry>
- <entry><constant>INVALID_LENGTH</constant></entry>
- <entry>upcaInvalidLength</entry>
- </row>
- <row>
- <entry><classname>Digits</classname></entry>
- <entry><constant>STRING_EMPTY</constant></entry>
- <entry>digitsStringEmpty</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
- </sect2>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|