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

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