source: trunk/docs/codebase_v1-to-v2_upgrade_checklist.txt @ 239

Last change on this file since 239 was 239, checked in by jordan, 17 years ago

Q - fixed ; in mysql upgrade. Jordan - many fixes to upgrade checklist.

File size: 10.6 KB
Line 
1<?php
2
3=====================================================================
4In General
5=====================================================================
6
71. Include methods have changed. Instead of accessing file paths absolutely, all files are searched in the include_path. So, instead of:
8
9    include SITE_BASE . '/_templates/header.ihtml';
10   
11do this:
12
13    include 'header.ihtml';
14   
15
162. CODE_BASE is a defunct constant. The location of the codebase is no longer important as long as it can be found in the currently configured include_path. This will usually include the local site directory (where the codebase normally would be found) as well as the server-wide /usr/lib/php directory where the codebase might be included for the whole server. So now, instead of this:
17
18    require_once CODE_BASE . '/lib/Utilities.inc.php';
19   
20do this:
21
22    require_once 'codebase/lib/Utilities.inc.php';
23   
24   
253. $CFG-> variables are gone. Most of these should be converted into their $app and $auth equivelents. If a $CFG variable is NOT something used by the codebase but is still needed by the website application, I suggest converting these values to a $cfg array. For example, this:
26
27    $CFG->gallery_images_url = '/gallery_images';
28   
29should become:
30
31    $cfg['gallery_images_url'] = '/gallery_images';
32   
33And of course change the code where they are used to support the array instead of object-properties. If the array is inside of double-quotes it should be written like:
34
35    "{$cfg['gallery_images_url']}/my/path".
36   
37If the value used is now to be retreived from a $object->getParam(...) method call, you'll need to do this:
38
39    $object->getParam('gallery_images_url') . '/my/path'
40
41
424. $CFG->site_url is not needed when referencing URLs. Change this:
43
44    <a href="<?php echo ohref("$CFG->site_url/my/file.php"); ?>">
45   
46to this:
47
48    <a href="<?php echo $app->ohref("/my/file.php"); ?>">
49   
50(In otherwords, the URL should be a not-fully-qualified URL starting with a slash.)
51
52
53// 5. Expect formatting incosistencies! When doing global search-replace expect whitespace to be erratic, variable names to change, and lines to be otherwise inconsistent. Here's a good example of a safe way to match a line:
54
55Searching for "$CFG->ssl_domain = 'www.example.com';":
56
57//    $CFG->(\w+)\s*=\s*['"](\w+)['"];
58
59Replace:
60
61    $app->setParam(array(
62        '\1' => '\2'
63    ));
64   
65   
666. Many classes now require object-method calls, and the object must be globally scoped. For example, to call the $cache->exists() method inside a function, be sure to add:
67
68    global $cache;
69   
70at the top of the function.
71
72   
73
74=====================================================================
75App
76=====================================================================
77
78The _config.inc.php file is 99% different. Start over from scratch using codebase/docs/example_config.inc.php.
79
80---------------------------------------------------------------------
81$CFG global variables are converted to object properties specific to their usage.
82   
83For example:
84
85    $CFG->ssl_domain = 'www.example.com';
86    $CFG->login_timeout = 21600;
87
88are converted to:
89
90    $app->setParam(array(
91        'ssl_domain' => 'www.example.com'
92    ));
93    $auth->setParam(array(
94        'login_timeout'     => 21600,
95    ));
96
97---------------------------------------------------------------------
98Convert functions to methods.
99
100raiseMsg(...)                           $app->raiseMsg(...)
101logMsg(...)                             $app->logMsg(...)
102include 'message_header.ihtml';         $app->printRaisedMessages();
103$carry_queries = array(... , ...);      $app->carryQuery(...);  //call for each value in array
104ohref(...)                              $app->ohref(...)
105printHiddenSession();                   $app->printHiddenSession();
106dieURL(...);                            $app->dieURL(...);
107dieBoomerangURL(...);                   $app->dieBoomerangURL(...);
108setBoomerangURL(...);                   $app->setBoomerangURL(...);
109getBoomerangURL(...);                   $app->getBoomerangURL(...);
110validBoomerangURL(...);                 $app->validBoomerangURL(...);
111deleteBoomerangURL(...);                $app->deleteBoomerangURL(...);
112sslOn();                                $app->sslOn();
113sslOff();                               $app->sslOff();
114
115$CFG->site_name                         $app->getParam('site_name')
116
117=====================================================================
118DB
119=====================================================================
120
121dbQuery(...)                            $db->query(...)
122dbTableExists(...)                      $db->tableExists(...)
123addslashes(...)                         $db->escapeString(...)
124
125
126=====================================================================
127Auth_SQL
128=====================================================================
129
130$auth->clearAuth()                      $auth->clear()
131$auth->setVal(...)                      $auth->set(...)
132$auth->getVal(...)                      $auth->get(...)
133$auth->setFeature(...)                  $auth->setParam(...)
134$auth->getFeature(...)                  $auth->getParam(...)
135
136
137=====================================================================
138ImageThumb
139=====================================================================
140
141$thumb->setSourceDirectory(...)         $thumb->setParam(array('source_dir' => ...))
142$thumb->createDestDirs(...)             $this->_createDestDirs(...) NOW PRIVATE!
143$thumb->validFileExtension(...)         $this->_validFileExtension(...) NOW PRIVATE!
144
145=====================================================================
146MySQLSessionHandler
147=====================================================================
148
149Renamed to DBSessionHandler.inc.php
150Interface totally changed. See example in App.inc.php.
151
152=====================================================================
153Navigation
154=====================================================================
155
156Renamed to Navigation.inc.php
157
158$nav->addPage(...)                      $nav->add(...)
159$nav->setFeature(array(...))            $nav->set(...)
160$nav->getFeature(...)                   $nav->get(...)
161$nav->getTitle()                        $nav->get('title')
162$nav->printTitle()                      echo $nav->get('title')
163$nav->getPath()                         $nav->get('path')
164$nav->printPath()                       echo $nav->get('path')
165$nav->printBreadcrumbs()                echo $nav->getBreadcrumbs()
166
167$nav->path_delimiter                    $nav->getParam('path_delimiter')
168NOTE: this applies to any object property that has been converted to a param.
169
170
171=====================================================================
172PEdit
173=====================================================================
174
175Massive changes. See quinn.
176
177=====================================================================
178Prefs
179=====================================================================
180
181$prefs = new Prefs($dbh, $params)       $prefs = new Prefs('namespace')
182NOTE: new instantiation interface
183
184$prefs->setDefault(..., scope)                 $prefs->setDefaults(array(...))
185NOTE: plurality - function need not be called once-per-default.
186
187$prefs->setValue(..., $scope)           $prefs->set(...)
188$prefs->getValue(..., $scope)           $prefs->get(...)
189$prefs->clearValue(..., $scope)         $prefs->delete(...)
190NOTE: $scope no longer used in the above methods.
191
192$prefs->retrieve()                      $prefs->load()
193
194=====================================================================
195Lock
196=====================================================================
197
198Renamed from RecordLock.inc.php to Lock.inc.php
199
200Only one major interface change: instead of calling $lock->dieErrorPage() you will wrap the header/footer includes around the method call $lock->printErrorHTML().
201
202Also, change instantiation call from:
203
204    $lock = new RecordLock($GLOBALS['_admin']);
205   
206to:
207
208    global $lock;
209    global $auth;
210    $lock =& Lock::getInstance($auth);
211     
212And instantiate the original global $lock object in _config.inc.php as follows:
213
214    // Global record-locking object.
215    $lock =& Lock::getInstance($auth);
216    $lock->setParam(array(
217        'timeout' => 0,
218        'auto_timeout' => 1800,
219        'error_url' => '/lock.php',
220    ));
221
222
223=====================================================================
224Version
225=====================================================================
226
227Renamed from RecordVersion.inc.php to Version.inc.php
228
229Change usage from:
230
231    $version = new RecordVersion();
232   
233to:
234
235    $version =& Version::getInstance($auth);
236
237
238=====================================================================
239Cache
240=====================================================================
241
242Renamed from SessionCache.inc.php to Cache.inc.php
243
244Changed all method calls to now require object calls rather than static calls. In other words, change this:
245
246    if (SessionCache::isCached('mydata')) {
247        $list = SessionCache::getCache('mydata');
248    }
249
250to:
251
252    if ($cache->exists('mydata')) {
253        $node_list = $cache->get('mydata');
254    }
255
256And have $cache instantiated in _config.inc.php like this:
257
258    // Global cache object.
259    $cache = new Cache('global');
260    $cache->setParam(array('enabled' => true));
261
262
263SessionCache::putCache($val, $key)      $cache->set($key, $val)
264NOTE: notice method arguments have been reversed.
265
266SessionCache::getCache(...)             $cache->get(...)
267SessionCache::isCached(...)             $cache->exists(...)
268SessionCache::breakCache(...)           $cache->delete(...)
269
270
271=====================================================================
272Upload
273=====================================================================
274
275Change all object properties from direct access to method-access:
276
277$file->allow_overwriting = true;        $file->setParam('allow_overwriting', true);
278$file->valid_file_extensions = true;        $file->setParam('valid_file_extensions', true);
279$file->dest_file_perms = 0666;        $file->setParam('dest_file_perms', 0666);
280...etc.
281
282$file->setUploadPath(...)               $file->setParam(array('upload_path' => ...))
283
284
285=====================================================================
286Utilities
287=====================================================================
288
289humanFileSize($size, $unit, $format)    humanFileSize($size, $format, $max_unit)
290NOTE: changed interface
291
292dbArrayToList(...)                      escapedList(...)
293NOTE: The functionality of this has changed, better check output is valid.
294
295=====================================================================
296FormValidator
297=====================================================================
298
299include 'form_error_header.ihtml';      $fv->printErrorMessages();
300
301
302?>
Note: See TracBrowser for help on using the repository browser.