Development

/branches/1.3/UPGRADE_TO_1_3

You must first sign up to be able to contribute.

root/branches/1.3/UPGRADE_TO_1_3

Revision 19412, 10.9 kB (checked in by fabien, 4 years ago)

[1.3] updated the list of deprecated methods

Line 
1 Upgrading Projects from 1.2 to 1.3
2 ==================================
3
4 This document describes the changes made in symfony 1.3 and what need
5 to be done to upgrade your symfony 1.2 projects.
6
7 If you want more detailed information on what has been changed/added in symfony 1.3,
8 you can read the [What's new?](http://www.symfony-project.org/tutorial/1_3/whats-new) tutorial.
9
10 >**CAUTION**
11 >symfony 1.3 is compatible with PHP 5.2.4 or later.
12 >It might also work with PHP 5.2.0 to 5.2.3 but there is no guarantee.
13
14 How to upgrade?
15 ---------------
16
17 To upgrade a project:
18
19   * Check that all plugins used by your project are compatible with symfony
20     1.3
21
22   * If you don't use a SCM tool, please make a backup of your project.
23
24   * Upgrade symfony to 1.3
25
26   * Upgrade the plugins to their 1.3 version
27
28   * Launch the `project:upgrade1.3` task from your project directory
29     to perform an automatic upgrade:
30
31         $ php symfony project:upgrade1.3
32
33     This task can be launched several times without any side effect. Each time
34     you upgrade to a new symfony 1.3 beta / RC or the final symfony 1.3, you
35     have to launch this task.
36
37   * You need to rebuild your models and forms due to some changes described
38     below:
39
40         $ php symfony doctrine:build-model
41         $ php symfony doctrine:build-forms
42         $ php symfony doctrine:build-filters
43
44   * Clear the cache:
45
46         $ php symfony cc
47
48 The remaining sections explain the main changes made in symfony 1.3 that need
49 some kind of upgrade (automatic or not).
50
51 Deprecated/Removed settings, classes, methods, functions, and tasks
52 -------------------------------------------------------------------
53
54 Symfony 1.3 is the last version for which the sfCompat10Plugin plugin is
55 included. The plugin will be removed in symfony 1.4.
56
57 The following methods and functions have been deprecated in symfony 1.3 or
58 before, and will be removed in symfony 1.4:
59
60   * `sfToolkit::getTmpDir()`: You can replace all occurrences of this method
61     by `sys_get_temp_dir()`
62
63   * `sfForm::setInvalidMessage()`: You can replace it by a call to the new
64     `sfForm::setDefaultMessage()` method
65
66   * `sfForm::setRequiredMessage()`: You can replace it by a call to the new
67     `sfForm::setDefaultMessage()` method
68
69   * `sfTesterResponse::contains()`: You can use the more powerful `matches()`
70     method
71
72   * `sfTestFunctionalBase` following methods: `isRedirected()`,
73     `isStatusCode()`, `responseContains()`, `isRequestParameter()`,
74     `isResponseHeader()`, `isUserCulture()`, `isRequestFormat()`, and
75     `checkResponseElement()`: These methods have been deprecated since 1.2,
76     and replaced with the tester classes.
77
78   * `sfFilesystem::sh()`: You can replace all occurrences of this method by
79     calls to the new `sfFilesystem::execute()` method. Be warned that the
80     returned value of this method is an array composed of the `stdout` output
81     and the `stderr` output.
82
83   * `sfAction::getDefaultView()`, `sfAction::handleError()`,
84     `sfAction::validate()`: These methods have been deprecated in symfony 1.1,
85     and they was not really useful. As of symfony 1.1, they need the
86     `compat_10` setting set to `on` to work.
87
88   * `sfComponent::debugMessage()`: Use the `log_message()` helper instead.
89
90   * `sfApplicationConfiguration::loadPluginConfig()`: Use
91     `initializePlugins()` instead.
92
93   * `sfLoader::getHelperDirs()` and `sfLoader::loadHelpers()`: Use the same
94     methods from the `sfApplicationConfiguration` object. As all methods of
95     the class `sfLoader` are deprecated, the `sfLoader` class will be removed
96     in symfony 1.4.
97
98   * `sfController::sendEmail()`
99
100   * `sfGeneratorManager::initialize()`: It does nothing.
101
102   * `debug_message()`: Use the `log_message()` helper instead.
103
104   * `sfWebRequest::getMethodName()`: Use `getMethod()` instead.
105
106   * `sfDomCssSelector::getTexts()` and `sfDomCssSelector::getElements()`
107
108 The following methods and functions have been removed in symfony 1.3:
109
110   * `sfApplicationConfiguration::checkSymfonyVersion()`: see below for the
111     explanation (`check_symfony_version` setting)
112
113 The following settings (managed in the `settings.yml` configuration file) have
114 been removed from symfony 1.3:
115
116   * `check_symfony_version`: This setting was introduced years ago to allow
117     automatic cache cleaning in case of a change of the symfony version. It
118     was mainly useful for shared hosting configuration where the symfony
119     version is shared amongst all customers. As this is bad practice since
120     symfony 1.1 (you need to embed the symfony version in each of your
121     project), the settings does not make sense anymore. Moreover, when the
122     setting is set to `on`, the check adds a small overhead to each request,
123     as we need to get the content of a file.
124
125   * `max_forwards`: This settings controls the number of forwards allowed
126     before symfony throws an exception. Making it configurable has no value.
127     If you need more than 5 forwards, you have both a conception problem and a
128     performance one.
129
130   * `sf_lazy_cache_key`: Introduced as a big performance improvement in
131     symfony 1.2.6, this setting allowed you to turn on a lazy cache key
132     generation for the view cache. While we think doing it lazy was the best
133     idea, some people might have relied on `sfViewCacheManager::isCacheable()`
134     being called even when the action itself wasn't cacheable. As of symfony
135     1.3, the behavior is the same as if `sf_lazy_cache_key` was set to `true`.
136
137   * `strip_comments`: The `strip_comments` was introduced to be able to
138     disable the comment stripping because of some bugs in the tokenizer of
139     some PHP 5.0.X versions. It was also used later on to avoid large memory
140     consumption when the Tokenizer extension was not compiled with PHP. The
141     first problem is not relevant anymore as the minimum version of PHP needed
142     is 5.2 and the second one has already been fixed by removing the regular
143     expression that simulated the comment stripping.
144
145 The following classes have been removed in symfony 1.3:
146
147   * `sfCommonFilter`: see the "Removal of the common filter" section for more
148     information about the consequences and how to migrate your code.
149
150 The following tasks have been removed in symfony 1.3:
151
152   * `project:freeze` and `project:unfreeze`: These tasks used to embed the
153     symfony version used by a project inside the project itself. They are not
154     needed anymore as the best practice has been to embed symfony in the
155     project for a very long time now. Moreover, switching from one version of
156     symfony to another is really simple now as you only need to change the
157     path in the `ProjectConfiguration` class. Embedding by hand symfony is
158     also very simple as you just need to copy the whole symfony directory
159     somewhere in your project (`lib/vendor/symfony/` is the recommended one).
160
161 The following tasks are deprecated in symfony 1.3, and will be removed in
162 symfony 1.4:
163
164   * All symfony 1.0 task aliases.
165
166 The following behaviors are deprecated in symfony 1.3, and will be removed in
167 symfony 1.4:
168
169   * The `sfParameterHolder::get()`, `sfParameterHolder::has()`,
170     `sfParameterHolder::remove()`, `sfNamespacedParameterHolder::get()`,
171     `sfNamespacedParameterHolder::has()`, and
172     `sfNamespacedParameterHolder::remove()` methods support for the array
173     notation (`[]`) is deprecated and won't be available in symfony 1.4
174     (better for performance).
175
176 The symfony CLI does not accept anymore the global `--dry-run` option as it
177 was not used by any symfony built-in task. If one of your task relies on this
178 option, you can just add it as a local option of your task class.
179
180 Autoloading
181 -----------
182
183 As of symfony 1.3, the files under the `lib/vendor/` directory are not
184 autoloaded anymore by default. If you want to autoload some `lib/vendor/`
185 sub-directories, add a new entry in the application `autoload.yml`
186 configuration file:
187
188     [yml]
189     autoload:
190       vendor_some_lib:
191         name:      vendor_some_lib
192         path:      %SF_LIB_DIR%/vendor/some_lib_dir
193         recursive: on
194
195 The automatic autoloading of the `lib/vendor/` directory was problematic for
196 several reasons:
197
198   * If you put a library under the `lib/vendor/` directory that already has an
199     autoload mechanism, symfony will re-parse the files and add a bunch of
200     unneeded information in the cache
201     (see #5893 - http://trac.symfony-project.org/ticket/5893).
202
203   * If your symfony directory is not exactly named `lib/vendor/symfony/`, the
204     project autoloader will re-parse the whole symfony directory and some
205     problems might occur
206     (see #6064 - http://trac.symfony-project.org/ticket/6064).
207
208 Routing
209 -------
210
211 The `sfPatternRouting::setRoutes()`, `sfPatternRouting::prependRoutes()`,
212 `sfPatternRouting::insertRouteBefore()`, and `sfPatternRouting::connect()`
213 methods do not return the routes as an array as they did in previous versions.
214
215 JavaScripts and Stylesheets
216 ---------------------------
217
218 ### Removal of the common filter
219
220 The `sfCommonFilter` has been removed. This filter used to automatically
221 inject the JavaScripts and stylesheets tags into the response content. You now
222 need to manually include these assets by explicitly call the
223 `include_stylesheets()` and `include_javascripts()` helpers in your layout:
224
225     [php]
226     <?php include_javascripts() ?>
227     <?php include_stylesheets() ?>
228
229 It has been removed for several reasons:
230
231  * We already have a better, simple, and more flexible solution (the
232    `include_stylesheets()` and `include_javascripts()` helpers)
233
234  * Even if the filter can be easily disabled, it is not an easy task as you
235    must first know about its existence and its "behind the scene" magic work
236
237  * Using the helpers provides more fined-grained control over when and where
238    the assets are included in the layout (the stylesheets in the `head` tag,
239    and the JavaScripts just before the end of the `body` tag for instance)
240
241  * It is always better to be explicit, rather than implicit (no magic and no
242    WTF effect; see the user mailing-list for a lot of complaints on this
243    issue)
244
245  * It provides a small speed improvement
246
247 How to upgrade?
248
249   * The `common` filter need to be removed from all `filters.yml`
250     configuration files (this is automatically done by the
251     `project:upgrade1.3` task).
252
253   * You need to add `include_stylesheets()` and `include_javascripts()` calls
254     in your layout(s) to have the same behavior as before (this is
255     automatically done by the `project:upgrade1.3` task for HTML layouts
256     contained in the `templates/` directories of your applications - they must
257     have a `<head>` tag though; and you need to manually upgrade any other
258     layout, or any page that does not have a layout but still relies on
259     JavaScripts files and/or stylesheets).
260
261 Tasks
262 -----
263
264 ### Formatters
265
266 The `sfFormatter::format()` third argument has been removed.
267
268 Escaping
269 --------
270
271 The `esc_js_no_entities()`, refered to by `ESC_JS_NO_ENTITIES` was updated to
272 correctly handle non-ANSI characters. Before this change only characters with
273 ANSI value `37` to `177` were not escaped. Now it will only escape backslashes
274 `\`, quotes `'` & `"` and linebreaks `\n` & `\r`.
275
Note: See TracBrowser for help on using the browser.