| 1 |
<?php
|
| 2 |
// $Id: deadwood.notifies.inc,v 1.2 2008/08/25 20:50:48 solotandem Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Generate version upgrade code from 5.x to 6.x.
|
| 7 |
*
|
| 8 |
* The functions in this file match up with the 80 topics in the roadmap at
|
| 9 |
* http://drupal.org/node/114774. As the topics sometimes overlap, there is
|
| 10 |
* a corresponding redundancy in the functions. The hope for the 7.x version
|
| 11 |
* of this module is that the 7.x roadmap will be written without any
|
| 12 |
* overlap in topics.
|
| 13 |
*
|
| 14 |
* This includes 6 topics in the menu API roadmap at
|
| 15 |
* http://drupal.org/node/103114.
|
| 16 |
*
|
| 17 |
* Copyright 2008 by Jim Berry ("solotandem", http://drupal.org/user/240748)
|
| 18 |
*/
|
| 19 |
|
| 20 |
/**
|
| 21 |
* Convert calls to format_plural() to allow for variable replacements like t().
|
| 22 |
*
|
| 23 |
* @param string $file The file to convert.
|
| 24 |
*/
|
| 25 |
function deadwood_convert_format_plural(&$file) {
|
| 26 |
$hook = 'format_plural';
|
| 27 |
$cur = $file;
|
| 28 |
$new = $cur;
|
| 29 |
|
| 30 |
// Check for references to format_plural.
|
| 31 |
$pattern = '/format_plural\s*\(/';
|
| 32 |
if (!preg_match($pattern, $file, $matches)) {
|
| 33 |
return;
|
| 34 |
}
|
| 35 |
|
| 36 |
$msg = "/* TODO\n" .
|
| 37 |
" An argument for replacements has been added to format_plural(),\n" .
|
| 38 |
" escaping and/or theming the values just as done with t()." .
|
| 39 |
"*/";
|
| 40 |
|
| 41 |
$from = array();
|
| 42 |
$to = array();
|
| 43 |
// format_plural() accepts replacements.
|
| 44 |
/* 5.x code:
|
| 45 |
* strtr(format_plural($num, 'There is currently 1 %type post on your site.', 'There are currently @count %type posts on your site.'), array('%type' => theme('placeholder', $type)));
|
| 46 |
* becomes 6.x code:
|
| 47 |
* format_plural($num, 'There is currently 1 %type post on your site.', 'There are currently @count %type posts on your site.', array('%type' => $type));
|
| 48 |
*/
|
| 49 |
// $from[] = '/[\s(]strtr\s*\(format_plural\s*\(.*\),\s*array\(.*=>\s*theme\(.*,(\w)*\)/';
|
| 50 |
// $to[] = $msg . '$1'; // We could place the msg at the top of the file with other messages???
|
| 51 |
// $from[] = '/format_plural\s*\(/';
|
| 52 |
// $to[] = $msg . '$1';
|
| 53 |
// Find the Id line in the file.
|
| 54 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 55 |
$to[] = "$1\n$msg\n";
|
| 56 |
|
| 57 |
deadwood_do_conversions($from, $to, $new);
|
| 58 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 59 |
}
|
| 60 |
|
| 61 |
/**
|
| 62 |
* Add note about new language object.
|
| 63 |
*
|
| 64 |
* @param string $file The file to convert.
|
| 65 |
*/
|
| 66 |
function deadwood_convert_locale(&$file) {
|
| 67 |
$hook = 'locale';
|
| 68 |
$cur = $file;
|
| 69 |
$new = $cur;
|
| 70 |
|
| 71 |
// Check for references to locale.
|
| 72 |
$pattern = '/$locale/';
|
| 73 |
if (!preg_match($pattern, $file, $matches)) {
|
| 74 |
return;
|
| 75 |
}
|
| 76 |
|
| 77 |
$msg =
|
| 78 |
"/* TODO locale become language
|
| 79 |
With the improved language subsystem in Drupal, the global locale variable
|
| 80 |
(which contained a language code) is replaced with the global language object
|
| 81 |
(which contains properties for several language details). As with locale,
|
| 82 |
the new language object gives information about the language chosen for the
|
| 83 |
current page request. This change also affects themes, because Drupal now
|
| 84 |
knows about the directionality (left to right or right to left) of the
|
| 85 |
language used, and themes can make use of this information to output proper stylesheets. */";
|
| 86 |
|
| 87 |
// Find the Id line in the file.
|
| 88 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 89 |
$to[] = "$1\n$msg\n";
|
| 90 |
|
| 91 |
deadwood_do_conversions($from, $to, $new);
|
| 92 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 93 |
}
|
| 94 |
|
| 95 |
/**
|
| 96 |
* Add note about node/add automatic menu generation and alteration.
|
| 97 |
*
|
| 98 |
* @param string $file The file to convert.
|
| 99 |
*/
|
| 100 |
function deadwood_convert_node_add(&$file) {
|
| 101 |
$hook = 'menu';
|
| 102 |
$cur = deadwood_find_hook($hook, $file);
|
| 103 |
$new = $cur;
|
| 104 |
$hook = 'node_add';
|
| 105 |
|
| 106 |
$msg =
|
| 107 |
"/* TODO
|
| 108 |
The node/add/\$type menu items are now auto-generated by the menu system.
|
| 109 |
You should not declare them in your menu hook. This means that you can
|
| 110 |
use hook_menu_alter to change the visibility of an item or change the
|
| 111 |
access callback. */";
|
| 112 |
|
| 113 |
$from = array();
|
| 114 |
$to = array();
|
| 115 |
// TODO This is a good reason to combine the changes in the roadmap.
|
| 116 |
// This change is dependent on whether other menu changes are done since
|
| 117 |
// the path becomes the array index.
|
| 118 |
// node/add is now menu generated
|
| 119 |
$from[] = "/^(.*\$items.*\'path\'\s*=>\s*\'node\/add\/\w+)/m";
|
| 120 |
$to[] = "\n$msg\n\n$1";
|
| 121 |
// node/add is now menu generated (if other menu changes are done)
|
| 122 |
$from[] = '/^(\s*\$items\[\'node\/add\/\w+\'\]\s*=\s*array\s*\()/m';
|
| 123 |
$to[] = "\n$msg\n\n$1";
|
| 124 |
|
| 125 |
deadwood_do_conversions($from, $to, $new);
|
| 126 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 127 |
}
|
| 128 |
|
| 129 |
/**
|
| 130 |
* Add note about new hook_watchdog.
|
| 131 |
*
|
| 132 |
* @param string $file The file to convert.
|
| 133 |
*/
|
| 134 |
function deadwood_convert_hook_watchdog(&$file) {
|
| 135 |
$hook = 'hook_watchdog';
|
| 136 |
$cur = $file;
|
| 137 |
$new = $cur;
|
| 138 |
|
| 139 |
$msg =
|
| 140 |
"/* TODO
|
| 141 |
There is a new hook_watchdog in core. This means that contributed modules
|
| 142 |
can implement hook_watchdog to log Drupal events to custom destinations.
|
| 143 |
Two core modules are included, dblog.module (formerly known as watchdog.module),
|
| 144 |
and syslog.module. Other modules in contrib include an emaillog.module,
|
| 145 |
included in the logging_alerts module. See syslog or emaillog for an
|
| 146 |
example on how to implement hook_watchdog.
|
| 147 |
function example_watchdog(\$log = array()) {
|
| 148 |
if (\$log['severity'] == WATCHDOG_ALERT) {
|
| 149 |
mysms_send(\$log['user']->uid,
|
| 150 |
\$log['type'],
|
| 151 |
\$log['message'],
|
| 152 |
\$log['variables'],
|
| 153 |
\$log['severity'],
|
| 154 |
\$log['referer'],
|
| 155 |
\$log['ip'],
|
| 156 |
format_date(\$log['timestamp']));
|
| 157 |
}
|
| 158 |
} */";
|
| 159 |
|
| 160 |
// Find the Id line in the file.
|
| 161 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 162 |
$to[] = "$1\n$msg\n";
|
| 163 |
|
| 164 |
deadwood_do_conversions($from, $to, $new);
|
| 165 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 166 |
}
|
| 167 |
|
| 168 |
/**
|
| 169 |
* Specify PHP compatibility in .info files. (NOT DONE)
|
| 170 |
*
|
| 171 |
* @param string $file The file to convert.
|
| 172 |
*/
|
| 173 |
function deadwood_convert_info3(&$file) {
|
| 174 |
// $hook = 'info3';
|
| 175 |
// $cur = $file;
|
| 176 |
// $new = $cur;
|
| 177 |
|
| 178 |
// $from = array();
|
| 179 |
// $to = array();
|
| 180 |
// // Core compatibility now specified in .info files
|
| 181 |
// $from[] = '/(dependencies\s*=.*)$/m';
|
| 182 |
// $to[] = "$1\ncore = 6.x";
|
| 183 |
//
|
| 184 |
// deadwood_do_conversions($from, $to, $new);
|
| 185 |
//
|
| 186 |
// // New syntax for .info files
|
| 187 |
// $search = '/(dependencies)\s*=\s*(.+)/';
|
| 188 |
// $callback = 'deadwood_fix_dependencies';
|
| 189 |
// $chg = preg_replace_callback($search, $callback, $new);
|
| 190 |
// $new = $chg != '' ? $chg : $new;
|
| 191 |
//
|
| 192 |
// deadwood_save_changes($cur, $new, $file, $hook);
|
| 193 |
}
|
| 194 |
|
| 195 |
/**
|
| 196 |
* Add note about changes to node_revision_list.
|
| 197 |
*
|
| 198 |
* @param string $file The file to convert.
|
| 199 |
*/
|
| 200 |
function deadwood_convert_node_revision_list(&$file) {
|
| 201 |
$hook = 'node_revision_list';
|
| 202 |
$cur = $file;
|
| 203 |
$new = $cur;
|
| 204 |
|
| 205 |
// Check for calls to node_revision_list.
|
| 206 |
$pattern = '/node_revision_list\s*\(/';
|
| 207 |
if (!preg_match($pattern, $file, $matches)) {
|
| 208 |
return;
|
| 209 |
}
|
| 210 |
|
| 211 |
$msg =
|
| 212 |
"/* TODO node_revision_list() now returns keyed array
|
| 213 |
In previous versions of core, the node_revision_list() method returned an
|
| 214 |
ordered array, but there were no meaningful keys to index the data. If you
|
| 215 |
wanted to find information about a specific revision, you had to iterate
|
| 216 |
through the whole array until you found the revision ID you were looking for.
|
| 217 |
Now, the array is indexed by the revision ID (the vid column from the
|
| 218 |
{node_revisions} table) so if you're looking for information about a specific
|
| 219 |
revision, you can find it immediately. */";
|
| 220 |
|
| 221 |
// Find the Id line in the file.
|
| 222 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 223 |
$to[] = "$1\n$msg\n";
|
| 224 |
|
| 225 |
deadwood_do_conversions($from, $to, $new);
|
| 226 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 227 |
}
|
| 228 |
|
| 229 |
/**
|
| 230 |
* Add note about new user_mail_tokens.
|
| 231 |
*
|
| 232 |
* @param string $file The file to convert.
|
| 233 |
*/
|
| 234 |
function deadwood_convert_mail_tokens(&$file) {
|
| 235 |
$hook = 'mail_tokens';
|
| 236 |
$cur = $file;
|
| 237 |
$new = $cur;
|
| 238 |
|
| 239 |
$msg =
|
| 240 |
"/* TODO New user_mail_tokens() method may be useful.
|
| 241 |
user.module now provides a user_mail_tokens() function to return an array
|
| 242 |
of the tokens available for the email notification messages it sends when
|
| 243 |
accounts are created, activated, blocked, etc. Contributed modules that
|
| 244 |
wish to make use of the same tokens for their own needs are encouraged
|
| 245 |
to use this function. */";
|
| 246 |
|
| 247 |
// Find the Id line in the file.
|
| 248 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 249 |
$to[] = "$1\n$msg\n";
|
| 250 |
|
| 251 |
deadwood_do_conversions($from, $to, $new);
|
| 252 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 253 |
}
|
| 254 |
|
| 255 |
/**
|
| 256 |
* Add note about changes to files table.
|
| 257 |
*
|
| 258 |
* @param string $file The file to convert.
|
| 259 |
*/
|
| 260 |
function deadwood_convert_files_table(&$file) {
|
| 261 |
$hook = 'files_table';
|
| 262 |
$cur = $file;
|
| 263 |
$new = $cur;
|
| 264 |
|
| 265 |
// Check for references to {files} table.
|
| 266 |
$pattern = '/\{files\}\s*/';
|
| 267 |
if (!preg_match($pattern, $file, $matches)) {
|
| 268 |
return;
|
| 269 |
}
|
| 270 |
|
| 271 |
$msg =
|
| 272 |
"/* TODO {files} table changed
|
| 273 |
The files table has been changed to make it easier to preview uploaded files.
|
| 274 |
Two fields, status and timestamp, have been added so that temporary files
|
| 275 |
can be stored and cleaned automatically removed during a cron job. Use
|
| 276 |
file_set_status() to change a files status and make it a permanent file. */";
|
| 277 |
|
| 278 |
// Find the Id line in the file.
|
| 279 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 280 |
$to[] = "$1\n$msg\n";
|
| 281 |
|
| 282 |
deadwood_do_conversions($from, $to, $new);
|
| 283 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 284 |
}
|
| 285 |
|
| 286 |
/**
|
| 287 |
* Add note about displaying node form elements in previews.
|
| 288 |
*
|
| 289 |
* @param string $file The file to convert.
|
| 290 |
*/
|
| 291 |
function deadwood_convert_node_preview(&$file) {
|
| 292 |
$hook = 'node_info';
|
| 293 |
$cur = $file;
|
| 294 |
$new = $cur;
|
| 295 |
|
| 296 |
// Check for presence of hook_node_info function.
|
| 297 |
$exists = deadwood_find_hook($hook, $file);
|
| 298 |
if ($exists == '') {
|
| 299 |
return;
|
| 300 |
}
|
| 301 |
|
| 302 |
$msg =
|
| 303 |
"/* TODO Node previews and adding form fields to the node form.
|
| 304 |
There is a subtle but important difference in the way node previews (and other
|
| 305 |
such operations) are carried out when adding or editing a node. With the new
|
| 306 |
Forms API, the node form is handled as a multi-step form. When the node form
|
| 307 |
is previewed, all the form values are submitted, and the form is rebuilt with
|
| 308 |
those form values put into \$form['#node']. Thus, form elements that are added
|
| 309 |
to the node form will lose any user input unless they set their '#default_value'
|
| 310 |
elements using this embedded node object. */";
|
| 311 |
|
| 312 |
$from = array();
|
| 313 |
$to = array();
|
| 314 |
// Find the Id line in the file.
|
| 315 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 316 |
$to[] = "$1\n$msg\n";
|
| 317 |
|
| 318 |
$hook = 'node_preview';
|
| 319 |
deadwood_do_conversions($from, $to, $new);
|
| 320 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 321 |
}
|
| 322 |
|
| 323 |
/**
|
| 324 |
* Add note about new return value of hook_user.
|
| 325 |
*
|
| 326 |
* @param string $file The file to convert.
|
| 327 |
*/
|
| 328 |
function deadwood_convert_hook_user(&$file) {
|
| 329 |
$hook = 'user';
|
| 330 |
$cur = $file;
|
| 331 |
$new = $cur;
|
| 332 |
|
| 333 |
// Check for presence of hook_user function.
|
| 334 |
$exists = deadwood_find_hook($hook, $file);
|
| 335 |
if ($exists == '') {
|
| 336 |
return;
|
| 337 |
}
|
| 338 |
|
| 339 |
$msg =
|
| 340 |
"/* TODO hook_user('view')
|
| 341 |
The return value of hook_user('view') has changed, to match the process that
|
| 342 |
nodes use for rendering. Modules should add their custom HTML to
|
| 343 |
\$account->content element. Further, this HTML should be in the form that
|
| 344 |
drupal_render() recognizes. */";
|
| 345 |
|
| 346 |
$from = array();
|
| 347 |
$to = array();
|
| 348 |
// Find the Id line in the file.
|
| 349 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 350 |
$to[] = "$1\n$msg\n";
|
| 351 |
|
| 352 |
$hook = 'hook_user';
|
| 353 |
deadwood_do_conversions($from, $to, $new);
|
| 354 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 355 |
}
|
| 356 |
|
| 357 |
/**
|
| 358 |
* Add note about changing text of submit buttons.
|
| 359 |
*
|
| 360 |
* @param string $file The file to convert.
|
| 361 |
*/
|
| 362 |
function deadwood_convert_submit_buttons(&$file) {
|
| 363 |
$hook = 'submit_buttons';
|
| 364 |
$cur = $file;
|
| 365 |
$new = $cur;
|
| 366 |
|
| 367 |
// Check for presence of submit buttons.
|
| 368 |
$pattern = "/'#type'\s*=>\s*'submit'/";
|
| 369 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 370 |
return;
|
| 371 |
}
|
| 372 |
|
| 373 |
$msg =
|
| 374 |
"/* TODO Change 'Submit' to 'Save' on buttons
|
| 375 |
It has been agreed on that the description 'Submit' for a button is not a
|
| 376 |
good choice since it does not indicate what actually happens. While for
|
| 377 |
example on node editing forms, 'Preview' and 'Delete' describe exactly what
|
| 378 |
will happen when the user clicks on the button, 'Submit' only gives a vague
|
| 379 |
idea. When labelling your buttons, make sure that it is clear what this
|
| 380 |
button does when the user clicks on it. */";
|
| 381 |
|
| 382 |
$from = array();
|
| 383 |
$to = array();
|
| 384 |
// Find the Id line in the file.
|
| 385 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 386 |
$to[] = "$1\n$msg\n";
|
| 387 |
|
| 388 |
deadwood_do_conversions($from, $to, $new);
|
| 389 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 390 |
}
|
| 391 |
|
| 392 |
/**
|
| 393 |
* Add note about changed parameters for node_feed.
|
| 394 |
*
|
| 395 |
* @param string $file The file to convert.
|
| 396 |
*/
|
| 397 |
function deadwood_convert_node_feed(&$file) {
|
| 398 |
$hook = 'node_feed';
|
| 399 |
$cur = $file;
|
| 400 |
$new = $cur;
|
| 401 |
|
| 402 |
// Check for calls to node_feed function.
|
| 403 |
$pattern = "/node_feed\s*\(/";
|
| 404 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 405 |
return;
|
| 406 |
}
|
| 407 |
|
| 408 |
$msg =
|
| 409 |
"/* TODO node_feed() parameters changed
|
| 410 |
node_feed() now accepts an array of nids (i.e. integers), and not a database
|
| 411 |
result object. this is more flexible for callers but sometimes slighly less
|
| 412 |
efficient. */";
|
| 413 |
|
| 414 |
$from = array();
|
| 415 |
$to = array();
|
| 416 |
// Find the Id line in the file.
|
| 417 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 418 |
$to[] = "$1\n$msg\n";
|
| 419 |
|
| 420 |
deadwood_do_conversions($from, $to, $new);
|
| 421 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 422 |
}
|
| 423 |
|
| 424 |
/**
|
| 425 |
* Add note about replacement of submit operation in hook_nodeapi.
|
| 426 |
*
|
| 427 |
* @param string $file The file to convert.
|
| 428 |
*/
|
| 429 |
function deadwood_convert_hook_nodeapi(&$file) {
|
| 430 |
$hook = 'nodeapi';
|
| 431 |
$cur = $file;
|
| 432 |
$new = $cur;
|
| 433 |
|
| 434 |
// Check for presence of hook_nodeapi function.
|
| 435 |
$exists = deadwood_find_hook($hook, $file);
|
| 436 |
if ($exists == '') {
|
| 437 |
return;
|
| 438 |
}
|
| 439 |
|
| 440 |
// Check for presence of submit operation.
|
| 441 |
$pattern = "/'submit'/";
|
| 442 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 443 |
return;
|
| 444 |
}
|
| 445 |
|
| 446 |
// TODO This could just as easily be a conversion routine.
|
| 447 |
// Replace 'submit' with 'presave'.
|
| 448 |
|
| 449 |
$msg =
|
| 450 |
"/* TODO hook_nodeapi('submit') has been replaced by op='presave'
|
| 451 |
There is no longer a 'submit' op for nodeapi. Instead you may use the newly
|
| 452 |
created 'presave' op. Note, however, that this op is invoked at the beginning
|
| 453 |
of node_save(), in contrast to op='submit' which was invoked at the end of
|
| 454 |
node_submit(). Thus 'presave' operations will be performed on nodes that are
|
| 455 |
saved programatically via node_save(), while in Drupal 5.x op='submit' was
|
| 456 |
only applied to nodes saved via the node form. Note that the node form is now,
|
| 457 |
in effect, a multistep form (for example when previewing), so if you need to
|
| 458 |
fix up the data in the node for re-building the form, use a #submit function
|
| 459 |
added to the node form's \$form array. */";
|
| 460 |
|
| 461 |
$from = array();
|
| 462 |
$to = array();
|
| 463 |
// Find the Id line in the file.
|
| 464 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 465 |
$to[] = "$1\n$msg\n";
|
| 466 |
|
| 467 |
$hook = 'hook_nodeapi';
|
| 468 |
deadwood_do_conversions($from, $to, $new);
|
| 469 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 470 |
}
|
| 471 |
|
| 472 |
/**
|
| 473 |
* Add note about elimination of db_num_rows function.
|
| 474 |
*
|
| 475 |
* @param string $file The file to convert.
|
| 476 |
*/
|
| 477 |
function deadwood_convert_db_num_rows(&$file) {
|
| 478 |
$hook = 'db_num_rows';
|
| 479 |
$cur = $file;
|
| 480 |
$new = $cur;
|
| 481 |
|
| 482 |
// Check for calls to db_num_rows function.
|
| 483 |
$pattern = "/db_num_rows\s*\(/";
|
| 484 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 485 |
return;
|
| 486 |
}
|
| 487 |
|
| 488 |
$msg =
|
| 489 |
"/* TODO Remove db_num_rows() method
|
| 490 |
The db_num_rows() method was removed from the database abstraction layer in
|
| 491 |
6.x core, as it was a database dependent method. Developers need to use other
|
| 492 |
handling to replace the needs of this method. */";
|
| 493 |
|
| 494 |
$from = array();
|
| 495 |
$to = array();
|
| 496 |
// Find the Id line in the file.
|
| 497 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 498 |
$to[] = "$1\n$msg\n";
|
| 499 |
|
| 500 |
deadwood_do_conversions($from, $to, $new);
|
| 501 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 502 |
}
|
| 503 |
|
| 504 |
/**
|
| 505 |
* Add note about elimination of $row argument from db_result function.
|
| 506 |
*
|
| 507 |
* @param string $file The file to convert.
|
| 508 |
*/
|
| 509 |
function deadwood_convert_row_argument(&$file) {
|
| 510 |
$hook = 'row_argument';
|
| 511 |
$cur = $file;
|
| 512 |
$new = $cur;
|
| 513 |
|
| 514 |
// Check for calls to db_num_rows function.
|
| 515 |
// TODO Actual calls to this function may have more complicated argument for
|
| 516 |
// first parameter and cause this to find something.
|
| 517 |
$pattern = "/db_result\s*\((.+?),\s*(.+?)\)/";
|
| 518 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 519 |
return;
|
| 520 |
}
|
| 521 |
|
| 522 |
$msg =
|
| 523 |
"/* TODO Remove \$row argument from db_result() method
|
| 524 |
The \$row argument of db_result() was removed from the database abstraction
|
| 525 |
layer in 6.x core, as it was a database dependent option. Developers need to
|
| 526 |
use other handling to replace the needs of this method. */";
|
| 527 |
|
| 528 |
$from = array();
|
| 529 |
$to = array();
|
| 530 |
// Find the Id line in the file.
|
| 531 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 532 |
$to[] = "$1\n$msg\n";
|
| 533 |
|
| 534 |
deadwood_do_conversions($from, $to, $new);
|
| 535 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 536 |
}
|
| 537 |
|
| 538 |
/**
|
| 539 |
* Add note about not calling node_access_rebuild themselves on enable/disable.
|
| 540 |
*
|
| 541 |
* @param string $file The file to convert.
|
| 542 |
*/
|
| 543 |
function deadwood_convert_node_access_rebuild1(&$file) {
|
| 544 |
$hook = 'node_access_rebuild';
|
| 545 |
$cur = $file;
|
| 546 |
$new = $cur;
|
| 547 |
|
| 548 |
// Check for calls to node_access_rebuild function.
|
| 549 |
$pattern = "/node_access_rebuild\s*\(/";
|
| 550 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 551 |
return;
|
| 552 |
}
|
| 553 |
|
| 554 |
$msg =
|
| 555 |
"/* TODO Node access modules : simplified hook_enable / hook_disable / hook_node_access_records
|
| 556 |
In D5, modules defining node access permissions via hook_node_grants /
|
| 557 |
hook_node_access_records had to do a bit of hoop jumping : call
|
| 558 |
node_access_rebuild() in their hook_enable / hook_disable, check they're not
|
| 559 |
being disabled before actually returning their grants in hook_node_access_records()...
|
| 560 |
This is not required in D6 anymore : the system ensures the node grants are
|
| 561 |
rebuilt if needed when modules are enabled or disabled. Therefore, node access
|
| 562 |
modules should *not* call node_access_rebuild themselves on enable/disable. */";
|
| 563 |
|
| 564 |
$from = array();
|
| 565 |
$to = array();
|
| 566 |
// Find the Id line in the file.
|
| 567 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 568 |
$to[] = "$1\n$msg\n";
|
| 569 |
|
| 570 |
$hook = 'node_access_rebuild1';
|
| 571 |
deadwood_do_conversions($from, $to, $new);
|
| 572 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 573 |
}
|
| 574 |
|
| 575 |
/**
|
| 576 |
* Add note about new batch_mode parameter for node_access_rebuild.
|
| 577 |
*
|
| 578 |
* @param string $file The file to convert.
|
| 579 |
*/
|
| 580 |
function deadwood_convert_node_access_rebuild2(&$file) {
|
| 581 |
$hook = 'node_access_rebuild';
|
| 582 |
$cur = $file;
|
| 583 |
$new = $cur;
|
| 584 |
|
| 585 |
// Check for calls to node_access_rebuild function.
|
| 586 |
$pattern = "/node_access_rebuild\s*\(/";
|
| 587 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 588 |
return;
|
| 589 |
}
|
| 590 |
|
| 591 |
$msg =
|
| 592 |
"/* TODO node_access_rebuild(\$batch_mode = TRUE) / node_access_needs_rebuild()
|
| 593 |
To avoid PHP timeouts when rebuilding content access permissions (which can
|
| 594 |
critically leave the site's content half open), node_access_rebuild() now
|
| 595 |
accepts a \$batch_mode boolean parameter (defaults to FALSE), letting it
|
| 596 |
operate in 'progressive' mode using the new D6 batch processing (progressbar
|
| 597 |
processing, Ã la update.php).
|
| 598 |
See http://api.drupal.org/api/function/node_access_needs_rebuild/6. */";
|
| 599 |
|
| 600 |
$from = array();
|
| 601 |
$to = array();
|
| 602 |
// Find the Id line in the file.
|
| 603 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 604 |
$to[] = "$1\n$msg\n";
|
| 605 |
|
| 606 |
$hook = 'node_access_rebuild2';
|
| 607 |
deadwood_do_conversions($from, $to, $new);
|
| 608 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 609 |
}
|
| 610 |
|
| 611 |
/**
|
| 612 |
* Add note about book module rewrite.
|
| 613 |
*
|
| 614 |
* @param string $file The file to convert.
|
| 615 |
*/
|
| 616 |
function deadwood_convert_book(&$file) {
|
| 617 |
$hook = 'book';
|
| 618 |
$cur = $file;
|
| 619 |
$new = $cur;
|
| 620 |
|
| 621 |
// Check for calls to book module functions.
|
| 622 |
$pattern = "/book_\w+.*\s*\(/";
|
| 623 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 624 |
return;
|
| 625 |
}
|
| 626 |
|
| 627 |
$msg =
|
| 628 |
"/* TODO The book module has been rewritten to use the new menu system
|
| 629 |
The book module now makes use of the new Drupal 6.x menu system (e.g. the
|
| 630 |
{menu_links} table) to store and render the book hierarchy. Any modules that
|
| 631 |
previously interfaced with the book module will need to be re-written. All
|
| 632 |
the data loaded onto a node by the book module is now found in the
|
| 633 |
\$node->book attribute.
|
| 634 |
|
| 635 |
Many of the book module API function have changed. For example, function
|
| 636 |
book_recurse has been removed. For most use cases, this should be replaced by
|
| 637 |
book_export_traverse, but it no longer has a \$depth parameter. */";
|
| 638 |
|
| 639 |
$from = array();
|
| 640 |
$to = array();
|
| 641 |
// Find the Id line in the file.
|
| 642 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 643 |
$to[] = "$1\n$msg\n";
|
| 644 |
|
| 645 |
deadwood_do_conversions($from, $to, $new);
|
| 646 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 647 |
}
|
| 648 |
|
| 649 |
/**
|
| 650 |
* Add note about checking node access before emailing content.
|
| 651 |
*
|
| 652 |
* @param string $file The file to convert.
|
| 653 |
*/
|
| 654 |
function deadwood_convert_email_node_access(&$file) {
|
| 655 |
$hook = 'email_node_access';
|
| 656 |
$cur = $file;
|
| 657 |
$new = $cur;
|
| 658 |
|
| 659 |
// Check for calls to drupal_mail function.
|
| 660 |
$pattern = "/drupal_mail\s*\(/";
|
| 661 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 662 |
return;
|
| 663 |
}
|
| 664 |
|
| 665 |
$msg =
|
| 666 |
"/* TODO Check node access before emailing content
|
| 667 |
Modules like Organic Groups and Project Issue send the same content as an
|
| 668 |
email notifications to many users. They should now be using the new 3rd
|
| 669 |
parameter to node_access() to check access on the content before emailing it.
|
| 670 |
Note that db_rewrite_sql() provodes no protection because the recipient is not
|
| 671 |
the logged in user who is receiving the content. */";
|
| 672 |
|
| 673 |
$from = array();
|
| 674 |
$to = array();
|
| 675 |
// Find the Id line in the file.
|
| 676 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 677 |
$to[] = "$1\n$msg\n";
|
| 678 |
|
| 679 |
deadwood_do_conversions($from, $to, $new);
|
| 680 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 681 |
}
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
// INSERT ABOVE
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
/**
|
| 690 |
* Add note about FormAPI image buttons.
|
| 691 |
*
|
| 692 |
* @param string $file The file to convert.
|
| 693 |
*/
|
| 694 |
function deadwood_convert_image_buttons(&$file) {
|
| 695 |
$hook = 'image_buttons';
|
| 696 |
$cur = $file;
|
| 697 |
$new = $cur;
|
| 698 |
|
| 699 |
$msg =
|
| 700 |
"/* TODO FormAPI image buttons are now supported.
|
| 701 |
FormAPI now offers the 'image_button' element type, allowing developers to
|
| 702 |
use icons or other custom images in place of traditional HTML submit buttons.
|
| 703 |
|
| 704 |
\$form['my_image_button'] = array(
|
| 705 |
'#type' => 'image_button',
|
| 706 |
'#title' => t('My button'),
|
| 707 |
'#return_value' => 'my_data',
|
| 708 |
'#src' => 'my/image/path.jpg',
|
| 709 |
); */";
|
| 710 |
|
| 711 |
$from = array();
|
| 712 |
$to = array();
|
| 713 |
// Find the Id line in the file.
|
| 714 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 715 |
$to[] = "$1\n$msg\n";
|
| 716 |
|
| 717 |
deadwood_do_conversions($from, $to, $new);
|
| 718 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 719 |
}
|
| 720 |
|
| 721 |
/**
|
| 722 |
* Add note about db_last_insert_id.
|
| 723 |
*
|
| 724 |
* @param string $file The file to convert.
|
| 725 |
*/
|
| 726 |
function deadwood_convert_db_last(&$file) {
|
| 727 |
$hook = 'db_last';
|
| 728 |
$cur = $file;
|
| 729 |
$new = $cur;
|
| 730 |
|
| 731 |
// Check for calls to db_next_id function.
|
| 732 |
$pattern = "/db_next_id\s*\(/";
|
| 733 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 734 |
return;
|
| 735 |
}
|
| 736 |
|
| 737 |
$msg =
|
| 738 |
"/* TODO db_next_id() is gone, and replaced as db_last_insert_id()
|
| 739 |
Since db_next_id() introduce some problems, and the use of this function
|
| 740 |
can be replaced by database level auto increment handling, db_next_id()
|
| 741 |
is now gone and replaced as db_last_insert_id() with help of serial type
|
| 742 |
under Schema API (check out http://drupal.org/node/149176 for more details).
|
| 743 |
Please refer to drupal_write_record() as demonstration. */";
|
| 744 |
|
| 745 |
$from = array();
|
| 746 |
$to = array();
|
| 747 |
// Find the Id line in the file.
|
| 748 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 749 |
$to[] = "$1\n$msg\n";
|
| 750 |
|
| 751 |
deadwood_do_conversions($from, $to, $new);
|
| 752 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 753 |
}
|
| 754 |
|
| 755 |
/**
|
| 756 |
* Add note about new hook_mail implementation.
|
| 757 |
*
|
| 758 |
* @param string $file The file to convert.
|
| 759 |
*/
|
| 760 |
function deadwood_convert_hook_mail(&$file) {
|
| 761 |
$hook = 'hook_mail';
|
| 762 |
$cur = $file;
|
| 763 |
$new = $cur;
|
| 764 |
|
| 765 |
// Check for calls to drupal_mail function.
|
| 766 |
$pattern = "/drupal_mail\s*\(/";
|
| 767 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 768 |
return;
|
| 769 |
}
|
| 770 |
|
| 771 |
$msg =
|
| 772 |
"/* TODO New hook_mail implementation
|
| 773 |
Because of changes to drupal_mail function, you need to move the variables
|
| 774 |
setup and string replace commands into the hook_mail implementation and then
|
| 775 |
call drupal_mail with the name of the module which contains this
|
| 776 |
implementation, the mailkey, the recipient, the language of the user the mail
|
| 777 |
goes to and some arbitrary parameters. */";
|
| 778 |
|
| 779 |
$from = array();
|
| 780 |
$to = array();
|
| 781 |
// Find the Id line in the file.
|
| 782 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 783 |
$to[] = "$1\n$msg\n";
|
| 784 |
|
| 785 |
deadwood_do_conversions($from, $to, $new);
|
| 786 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 787 |
}
|
| 788 |
|
| 789 |
/**
|
| 790 |
* Add note about drupal_set_breadcrumb.
|
| 791 |
*
|
| 792 |
* @param string $file The file to convert.
|
| 793 |
*/
|
| 794 |
function deadwood_convert_breadcrumb(&$file) {
|
| 795 |
$hook = 'breadcrumb';
|
| 796 |
$cur = $file;
|
| 797 |
$new = $cur;
|
| 798 |
|
| 799 |
// Check for calls to menu_set_location.
|
| 800 |
$pattern = "/menu_set_location/";
|
| 801 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 802 |
return;
|
| 803 |
}
|
| 804 |
|
| 805 |
$msg =
|
| 806 |
"/* TODO Use drupal_set_breadcrumb() instead of menu_set_location() to set
|
| 807 |
custom breadcrumbs.
|
| 808 |
Currently in D5, menu_set_location() is 'misused' in several modules to set
|
| 809 |
a custom breadcrumb, drupal_set_breadcrumb() should be used instead, as
|
| 810 |
discussed in #177497.
|
| 811 |
Note, when using drupal_set_breadcrumb(), you need to include 'home' but
|
| 812 |
not the current page.
|
| 813 |
Alternatively, if you do want to set the current location in the menu tree
|
| 814 |
as well as affect breadcrumbs, use menu_set_item(). */";
|
| 815 |
|
| 816 |
$from = array();
|
| 817 |
$to = array();
|
| 818 |
// Find the Id line in the file.
|
| 819 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 820 |
$to[] = "$1\n$msg\n";
|
| 821 |
|
| 822 |
deadwood_do_conversions($from, $to, $new);
|
| 823 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 824 |
}
|
| 825 |
|
| 826 |
/**
|
| 827 |
* Add note about Drupal.settings.basePath being automatically added.
|
| 828 |
*
|
| 829 |
* @param string $file The file to convert.
|
| 830 |
*/
|
| 831 |
function deadwood_convert_basePath(&$file) {
|
| 832 |
$hook = 'basePath';
|
| 833 |
$cur = $file;
|
| 834 |
$new = $cur;
|
| 835 |
|
| 836 |
// Check for calls to drupal_add_js function.
|
| 837 |
$pattern = "/drupal_add_js\s*\(/";
|
| 838 |
if (!preg_match($pattern, $cur, $matches)) {
|
| 839 |
return;
|
| 840 |
}
|
| 841 |
|
| 842 |
$msg =
|
| 843 |
"/* TODO Automatically add Drupal.settings.basePath
|
| 844 |
In Drupal 5, you would have to add the base path to Drupal.settings yourself
|
| 845 |
if you needed it (it's needed for just about every AHAH/AJAX enabled module
|
| 846 |
if you did it right). Now in Drupal 6, it's added automatically. You can always
|
| 847 |
find it at Drupal.settings.basePath (actually, as soon as drupal_add_js() is
|
| 848 |
called at least once, so this is similar to the way we automatically add
|
| 849 |
drupal.js and jquery.js. */";
|
| 850 |
|
| 851 |
$from = array();
|
| 852 |
$to = array();
|
| 853 |
// Find the Id line in the file.
|
| 854 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 855 |
$to[] = "$1\n$msg\n";
|
| 856 |
|
| 857 |
deadwood_do_conversions($from, $to, $new);
|
| 858 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 859 |
}
|
| 860 |
|
| 861 |
/**
|
| 862 |
* Add note about removal of hook_submit().
|
| 863 |
*
|
| 864 |
* @param string $file The file to convert.
|
| 865 |
*/
|
| 866 |
function deadwood_convert_hook_submit(&$file) {
|
| 867 |
$hook = 'node_info';
|
| 868 |
$cur = $file;
|
| 869 |
$new = $cur;
|
| 870 |
|
| 871 |
// Check for presence of hook_node_info function.
|
| 872 |
$exists = deadwood_find_hook($hook, $file);
|
| 873 |
if ($exists == '') {
|
| 874 |
return;
|
| 875 |
}
|
| 876 |
|
| 877 |
$msg =
|
| 878 |
"/* TODO hook_submit() has been removed
|
| 879 |
In Drupal 5.x, hook_submit() allowed node modules to alter the node before
|
| 880 |
saving it to the database (it was run between hook_validate() and
|
| 881 |
hook_insert()/hook_update()). In Drupal 6.x this hook has been removed.
|
| 882 |
Instead, you should attach a submit handler to the form created in hook_form(),
|
| 883 |
and then alter the \$form_state['values'] array as needed.
|
| 884 |
A submit handler would look like:
|
| 885 |
\$form['#submit'] = array('mymodule_node_form_submit_handler'); */";
|
| 886 |
|
| 887 |
$from = array();
|
| 888 |
$to = array();
|
| 889 |
// Find the Id line in the file.
|
| 890 |
$from[] = '/^(\/\/ \$Id.*\$\s*$)/m';
|
| 891 |
$to[] = "$1\n$msg\n";
|
| 892 |
|
| 893 |
$hook = 'hook_submit';
|
| 894 |
deadwood_do_conversions($from, $to, $new);
|
| 895 |
deadwood_save_changes($cur, $new, $file, $hook);
|
| 896 |
}
|