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