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

Last change on this file since 236 was 236, checked in by quinn, 17 years ago

Q - added v1 to v2 upgrade document.

File size: 10.1 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   
243. $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:
25
26    $CFG->gallery_images_url = '/gallery_images';
27   
28should become:
29
30    $cfg['gallery_images_url'] = '/gallery_images';
31   
32(And 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 "{$cfg['gallery_images_url']}/my/path".)
33
344. $CFG->site_url is not needed when referencing URLs. Change this:
35
36    <a href="<?php echo ohref("$CFG->site_url/my/file.php"); ?>">
37   
38to this:
39
40    <a href="<?php echo $app->ohref("/my/file.php"); ?>">
41   
42(In otherwords, the URL should be a not-fully-qualified URL starting with a slash.)
43   
44
45   
46
47=====================================================================
48App
49=====================================================================
50
51The _config.inc.php file is 99% different. Start over from scratch using codebase/docs/example_config.inc.php.
52
53---------------------------------------------------------------------
54$CFG global variables are converted to object properties specific to their usage.
55   
56For example:
57
58    $CFG->ssl_domain = 'www.example.com';
59    $CFG->login_timeout = 21600;
60
61are converted to:
62
63    $app->setParam(array(
64        'ssl_domain' => 'www.example.com'
65    ));
66    $auth->setParam(array(
67        'login_timeout'     => 21600,
68    ));
69
70---------------------------------------------------------------------
71Convert functions to methods.
72
73raiseMsg(...)                           $app->raiseMsg(...)
74logMsg(...)                             $app->logMsg(...)
75include 'message_header.ihtml';         $app->printRaisedMessages();
76$carry_queries = array(...);            $app->carryQuery(...);
77ohref(...)                              $app->ohref(...)
78printHiddenSession();                   $app->printHiddenSession();
79dieURL(...);                            $app->dieURL(...);
80dieBoomerangURL(...);                   $app->dieBoomerangURL(...);
81setBoomerangURL(...);                   $app->setBoomerangURL(...);
82getBoomerangURL(...);                   $app->getBoomerangURL(...);
83validBoomerangURL(...);                 $app->validBoomerangURL(...);
84deleteBoomerangURL(...);                $app->deleteBoomerangURL(...);
85sslOn();                                $app->sslOn();
86sslOff();                               $app->sslOff();
87
88
89=====================================================================
90DB
91=====================================================================
92
93dbQuery(...)                            $db->query(...)
94dbTableExists(...)                      $db->tableExists(...)
95addslashes(...)                         $db->escapeString(...)
96
97
98=====================================================================
99Auth_SQL
100=====================================================================
101
102$auth->clearAuth()                      $auth->clear()
103$auth->setVal(...)                      $auth->set(...)
104$auth->getVal(...)                      $auth->get(...)
105$auth->setFeature(...)                  $auth->setParam(...)
106$auth->getFeature(...)                  $auth->getParam(...)
107
108
109=====================================================================
110ImageThumb
111=====================================================================
112
113$thumb->setSourceDirectory(...)         $thumb->setParam(array('source_dir' => ...))
114$thumb->createDestDirs(...)             $this->_createDestDirs(...) NOW PRIVATE!
115$thumb->validFileExtension(...)         $this->_validFileExtension(...) NOW PRIVATE!
116
117=====================================================================
118MySQLSessionHandler
119=====================================================================
120
121Renamed to DBSessionHandler.inc.php
122Interface totally changed. See example in App.inc.php.
123
124=====================================================================
125Navigation
126=====================================================================
127
128Renamed to Navigation.inc.php
129
130$nav->addPage(...)                      $nav->add(...)
131$nav->setFeature(...)                   $nav->set(...)
132$nav->getFeature(...)                   $nav->get(...)
133$nav->getTitle()                        $nav->get('title')
134$nav->printTitle()                      echo $nav->get('title')
135$nav->getPath()                         $nav->get('path')
136$nav->printPath()                       echo $nav->get('path')
137$nav->getBreadcrumbs()                  $nav->getBreadcrumbs()
138$nav->printBreadcrumbs()                echo $nav->getBreadcrumbs()
139
140=====================================================================
141PEdit
142=====================================================================
143
144Massive changes. See quinn.
145
146=====================================================================
147Prefs
148=====================================================================
149
150$prefs = new Prefs($dbh, $params)       $prefs = new Prefs('namespace')
151NOTE: new instantiation interface
152
153$prefs->setDefault(...)                 $prefs->setDefaults(array(...))
154NOTE: plurality - function need not be called once-per-default.
155
156$prefs->setValue(..., $scope)           $prefs->set(...)
157$prefs->getValue(..., $scope)           $prefs->get(...)
158$prefs->clearValue(..., $scope)         $prefs->delete(...)
159NOTE: $scope no longer used in the above methods.
160
161$prefs->retrieve()                      $prefs->load()
162
163=====================================================================
164Lock
165=====================================================================
166
167Renamed from RecordLock.inc.php to Lock.inc.php
168
169Only one major interface change: instead of calling $lock->dieErrorPage() you will wrap the header/footer includes around the method call $lock->printErrorHTML().
170
171Also, change instantiation call from:
172
173    $lock = new RecordLock($GLOBALS['_admin']);
174   
175to:
176
177    global $lock;
178    $lock =& Lock::getInstance($auth);
179     
180And instantiate the original global $lock object in _config.inc.php as follows:
181
182    // Global record-locking object.
183    $lock =& Lock::getInstance($auth);
184    $lock->setParam(array(
185        'timeout' => 0,
186        'auto_timeout' => 1800,
187        'error_url' => '/lock.php',
188    ));
189
190
191=====================================================================
192Version
193=====================================================================
194
195Renamed from RecordVersion.inc.php to Version.inc.php
196
197Change usage from:
198
199    $version = new RecordVersion();
200   
201to:
202
203    $version = Version::getInstance($auth);
204
205
206=====================================================================
207Cache
208=====================================================================
209
210Renamed from SessionCache.inc.php to Cache.inc.php
211
212Changed all method calls to now require object calls rather than static calls. In other words, change this:
213
214    if (SessionCache::isCached('mydata')) {
215        $list = SessionCache::getCache('mydata');
216    }
217
218to:
219
220    if ($cache->exists('mydata')) {
221        $node_list = $cache->get('mydata');
222    }
223
224And have $cache instantiated in _config.inc.php like this:
225
226    // Global cache object.
227    $cache = new Cache('global');
228    $cache->setParam(array('enabled' => true));
229
230
231SessionCache::putCache($val, $key)      $cache->set($key, $val)
232NOTE: notice method arguments have been reversed.
233
234SessionCache::getCache(...)             $cache->set(...)
235SessionCache::isCached(...)             $cache->exists(...)
236SessionCache::breakCache(...)           $cache->delete(...)
237
238
239=====================================================================
240Upload
241=====================================================================
242
243Change all object properties from direct access to method-access:
244
245$file->allow_overwriting = true;        $file->setParam('allow_overwriting', true);
246$file->valid_file_extensions = true;        $file->setParam('valid_file_extensions', true);
247$file->$dest_file_perms = true;        $file->setParam('$dest_file_perms', true);
248...etc.
249
250$file->setUploadPath(...)               $file->setParam(array('upload_path' => ...))
251
252
253=====================================================================
254Utilities
255=====================================================================
256
257humanFileSize($size, $unit, $format)    humanFileSize($size, $format, $max_unit)
258NOTE: changed interface
259
260dbArrayToList(...)                      escapedList(...)
261NOTE: The functionality of this has changed, better check output is valid.
262
263
264=====================================================================
265HINTS
266=====================================================================
267
2681. 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:
269
270Searching for "$CFG->ssl_domain = 'www.example.com';":
271
272    $CFG->(\w+)\s*=\s*['"](\w+)['"];
273
274Replace:
275
276    $app->setParam(array(
277        '\1' => '\2'
278    ));
279   
2802. 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:
281
282    global $cache;
283   
284at the top of the function.
285
2863.
287
288
289?>
Note: See TracBrowser for help on using the repository browser.