source: tags/2.1.5/docs/codebase_v1-to-v2_upgrade_checklist.txt

Last change on this file was 334, checked in by quinn, 16 years ago

Fixed lots of misplings. I'm so embarrassed! ;P

File size: 10.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 equivalents. 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 retrieved 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 other words, the URL should be a not-fully-qualified URL starting with a slash.)
51
52
53// 5. Expect formatting inconsistencies! 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
115The following regex will find any of the above:
116(?<!raiseMsg|logMsg|include|ohref|printHiddenSession|dieURL|dieBoomerangURL|setBoomerangURL|getBoomerangURL|validBoomerangURL|deleteBoomerangURL|sslOn|sslOff)
117
118Also convert all site config variables, as earlier:
119$CFG->site_name                         $app->getParam('site_name')
120
121=====================================================================
122DB
123=====================================================================
124
125dbQuery(...)                            $db->query(...)
126dbTableExists(...)                      $db->tableExists(...)
127addslashes(...)                         $db->escapeString(...)
128
129$dbh
130$GLOBALS['dbh']                         $db->getDBH()
131
132=====================================================================
133Auth_SQL
134=====================================================================
135
136$auth->clearAuth()                      $auth->clear()
137$auth->setVal(...)                      $auth->set(...)
138$auth->getVal(...)                      $auth->get(...)
139$auth->setFeature(...)                  $auth->setParam(...)
140$auth->getFeature(...)                  $auth->getParam(...)
141
142
143=====================================================================
144ImageThumb
145=====================================================================
146
147$thumb->setSourceDirectory(...)         $thumb->setParam(array('source_dir' => ...))
148$thumb->createDestDirs(...)             $this->_createDestDirs(...) NOW PRIVATE!
149$thumb->validFileExtension(...)         $this->_validFileExtension(...) NOW PRIVATE!
150
151=====================================================================
152MySQLSessionHandler
153=====================================================================
154
155Renamed to DBSessionHandler.inc.php
156Interface totally changed. See example in App.inc.php.
157
158=====================================================================
159Navigation
160=====================================================================
161
162Renamed to Navigation.inc.php
163
164$nav->addPage(...)                      $nav->add(...)
165$nav->setFeature(array(...))            $nav->setParam(...)
166$nav->getFeature(...)                   $nav->getParam(...)
167$nav->getTitle()                        $nav->get('title')
168$nav->printTitle()                      echo $nav->get('title')
169$nav->getPath()                         $nav->get('path')
170$nav->printPath()                       echo $nav->get('path')
171$nav->printBreadcrumbs()                echo $nav->getBreadcrumbs()
172
173$nav->path_delimiter                    $nav->getParam('path_delimiter')
174NOTE: this applies to any object property that has been converted to a param.
175
176
177=====================================================================
178PEdit
179=====================================================================
180
181Massive changes. See Quinn.
182
183=====================================================================
184Prefs
185=====================================================================
186
187$prefs = new Prefs($dbh, $params)       $prefs = new Prefs('namespace')
188NOTE: new instantiation interface
189
190$prefs->setDefault(..., scope)                 $prefs->setDefaults(array(...))
191NOTE: plurality - function need not be called once-per-default.
192
193$prefs->setValue(..., $scope)           $prefs->set(...)
194$prefs->getValue(..., $scope)           $prefs->get(...)
195$prefs->clearValue(..., $scope)         $prefs->delete(...)
196NOTE: $scope no longer used in the above methods.
197
198$prefs->retrieve()                      $prefs->load()
199
200=====================================================================
201Lock
202=====================================================================
203
204Renamed from RecordLock.inc.php to Lock.inc.php
205
206Only one major interface change: instead of calling $lock->dieErrorPage() you will wrap the header/footer includes around the method call $lock->printErrorHTML().
207
208Also, change instantiation call from:
209
210    $lock = new RecordLock($GLOBALS['_admin']);
211   
212to:
213
214    global $lock;
215    global $auth;
216    $lock =& Lock::getInstance($auth);
217     
218And instantiate the original global $lock object in _config.inc.php as follows:
219
220    // Global record-locking object.
221    $lock =& Lock::getInstance($auth);
222    $lock->setParam(array(
223        'timeout' => 0,
224        'auto_timeout' => 1800,
225        'error_url' => '/lock.php',
226    ));
227
228
229=====================================================================
230Version
231=====================================================================
232
233Renamed from RecordVersion.inc.php to Version.inc.php
234
235Change usage from:
236
237    $version = new RecordVersion();
238   
239to:
240
241    $version =& Version::getInstance($auth);
242
243
244=====================================================================
245Cache
246=====================================================================
247
248Renamed from SessionCache.inc.php to Cache.inc.php
249
250Changed all method calls to now require object calls rather than static calls. In other words, change this:
251
252    if (SessionCache::isCached('mydata')) {
253        $list = SessionCache::getCache('mydata');
254    }
255
256to:
257
258    if ($cache->exists('mydata')) {
259        $list = $cache->get('mydata');
260    }
261
262And have $cache instantiated in _config.inc.php like this:
263
264    // Global cache object.
265    $cache = new Cache('global');
266    $cache->setParam(array('enabled' => true));
267
268
269SessionCache::putCache($val, $key)      $cache->set($key, $val)
270NOTE: notice method arguments have been reversed.
271
272SessionCache::getCache(...)             $cache->get(...)
273SessionCache::isCached(...)             $cache->exists(...)
274SessionCache::breakCache(...)           $cache->delete(...)
275
276
277=====================================================================
278Upload
279=====================================================================
280
281Change all object properties from direct access to method-access:
282
283$file->allow_overwriting = true;        $file->setParam('allow_overwriting', true);
284$file->valid_file_extensions = true;        $file->setParam('valid_file_extensions', true);
285$file->dest_file_perms = 0666;        $file->setParam('dest_file_perms', 0666);
286...etc.
287
288$file->setUploadPath(...)               $file->setParam(array('upload_path' => ...))
289
290
291=====================================================================
292Utilities
293=====================================================================
294
295humanFileSize($size, $unit, $format)    humanFileSize($size, $format, $max_unit)
296NOTE: changed interface
297
298dbArrayToList(...)                      escapedList(...)
299NOTE: The functionality of this has changed, better check output is valid.
300
301=====================================================================
302FormValidator
303=====================================================================
304
305include_once 'form_error_header.ihtml';      $fv->printErrorMessages();
306
307
308?>
Note: See TracBrowser for help on using the repository browser.