You are here

function coder_6x_reviews in Coder 5

Same name and namespace in other branches
  1. 5.2 includes/coder_6x.inc \coder_6x_reviews()
  2. 6.2 includes/coder_6x.inc \coder_6x_reviews()
  3. 6 includes/coder_6x.inc \coder_6x_reviews()

@file This include file implements coder functionality for 5.x -> 6.x upgrades

File

includes/coder_6x.inc, line 7
This include file implements coder functionality for 5.x -> 6.x upgrades

Code

function coder_6x_reviews() {
  $argex = '(([a-zA-Z_]+((\\([^)]*\\))|\\[[^\\]]*\\])?)|[0-9]+(\\.[0-9]*)?|\'\'|"")';
  $rules = array(
    array(
      '#type' => 'regex',
      '#function' => '_menu$',
      '#value' => '\\$items\\[\\]\\s*=|if\\s*\\(\\$may_cache\\)',
      '#warning_callback' => '_coder_6x_new_menu_system_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_form_alter\\s*\\(\\$',
      '#warning_callback' => '_coder_6x_form_alter_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_link_alter\\s*\\(\\$',
      '#warning_callback' => '_coder_6x_link_alter_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_profile_alter\\s*\\(\\$',
      '#warning_callback' => '_coder_6x_profile_alter_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_mail_alter\\s*\\([^,]+,',
      '#warning_callback' => '_coder_6x_mail_alter_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(](l|url)\\s*\\((' . $argex . ',\\s*){2,}(' . $argex . ')\\s*\\)',
      '#warning_callback' => '_coder_6x_url_l_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => 'global \\$locale',
      '#warning' => '$locale became $language',
    ),
    array(
      '#type' => 'regex',
      '#value' => '(taxonomy_node_get_terms|taxonomy_node_get_terms_by_vocabulary|taxonomy_node_delete_revision)\\s*\\(\\$(nid|node->nid)',
      '#warning_callback' => '_coder_6x_taxonomy_node_get_terms_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(]strtr\\s*\\(format_plural\\s*\\(',
      '#warning_callback' => '_coder_6x_format_plural_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => 'watchdog\\s*\\(\\s*\'\',\\s*t\\(\'',
      '#warning_callback' => '_coder_6x_watchdog_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(]cache_set\\s*\\(\\s*[^,]+,\\s*\'',
      '#warning_callback' => '_coder_6x_cache_set_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(]unserialize\\s*\\(\\s*cache_get\\s*\\(',
      '#warning_callback' => '_coder_6x_cache_get_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '\\$_SERVER\\s*\\[\\s*[\'"]REMOTE_ADDR[\'"]\\s*\\]',
      '#source' => 'all',
      '#warning_callback' => '_coder_6x_remote_addr_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(]file_check_upload\\s*\\(',
      '#warning_callback' => '_coder_6x_file_check_upload_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '((function)!\\s+|\\()file_save_upload\\s*\\([^,]+\\s*,\\s*[^,]+\\s*,',
      '#not' => 'function file_save_upload',
      '#warning_callback' => '_coder_6x_file_check_upload_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '\\{file_revisions\\}',
      '#warning' => 'The {file_revisions} table is now {upload}',
      '#source' => 'quote',
    ),
    array(
      '#type' => 'callback',
      '#value' => '_coder_6x_callback',
    ),
    // FAPI Rules
    array(
      '#type' => 'regex',
      '#source' => 'all',
      '#value' => '(\\$form\\s*\\[\\s*[\'"]#base[\'"]|[\'"]#base[\'"]\\s*=>)',
      '#warning' => 'FormAPI\'s #base property is gone, manually populate the $form[\'#submit\'], $form[\'#validate\'], and $form[\'#theme\'] elements with the proper function names',
    ),
    array(
      '#type' => 'regex',
      '#source' => 'all',
      '#value' => '\\$form\\s*\\[\\s*[\'"]#validate[\'"]\\]\\[[\'"]',
      '#warning' => 'Validation for specific form elements now uses the #element_validate property',
    ),
    array(
      '#type' => 'regex',
      '#source' => 'all',
      '#value' => '(\\$form\\s*\\[\\s*[\'"]#multistep[\'"]|[\'"]#multistep[\'"]\\s*=>)',
      '#warning' => '#multistep is gone, use $form_state instead',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_(validate|submit)\\s*\\(\\s*\\$form_id',
      '#warning_callback' => '_coder_6x_form_validate_and_submit_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '\\$form\\[[\'"]#submit[\'"]\\]\\[[\'"]',
      '#source' => 'all',
      '#warning' => '$form[\'#submit\'] and $form[\'#validate\'] no longer support custom parameters',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(]form_set_value\\s*\\([^,]+(,\\s*[^,\\)]+){0,1}\\)',
      '#warning_callback' => '_coder_6x_form_set_value_warning',
    ),
    /*  from Delete API, which has been reverted
        array(
          '#type' => 'regex',
          '#value' => '[\s\(]confirm_form\s*\([^,]+(,\s*[^,]+){4,}',
          '#warning_callback' => '_coder_6x_confirm_form_warning',
        ),
    */
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(]custom_url_rewrite\\s*\\(',
      '#warning_callback' => '_coder_6x_custom_url_rewrite_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_(info)\\s*\\(\\s*\\$field',
      '#warning_callback' => '_coder_6x_hook_info_auth_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_(auth)\\s*\\(\\s*\\$user',
      '#warning_callback' => '_coder_6x_hook_info_auth_warning',
    ),
    array(
      '#type' => 'regex',
      '#value' => '_(help)\\s*\\(\\s*[^,]+\\)',
      '#warning_callback' => '_coder_6x_hook_help_warning',
    ),
    array(
      '#type' => 'regex',
      '#source' => 'all',
      '#value' => '\\$form\\s*\\[\\s*[\'"]?op[\'"]?\\s*\\]|\\$form_values\\s*\\[\\s*[\'"]?op[\'"]?\\s*\\]',
      '#warning' => 'replace $form[\'op\'] with $form_state[\'values\'][\'op\']',
    ),
    array(
      '#type' => 'regex',
      '#source' => 'all',
      '#function' => '_(un)?install$|_update_[0-9]+$',
      '#value' => '\\$GLOBALS\\[[\'"]?db_type[\'"]?\\]',
      '#warning_callback' => '_coder_6x_schema_api_warning',
    ),
    array(
      '#type' => 'regex',
      '#source' => 'all',
      '#function' => '_submit$|_validate$',
      '#value' => '\\$form(_values)?\\[[\'"][A-Za-z]',
      '#warning' => 'use $form_state[\'values\'] instead, which is where the values are stored after a submit',
    ),
    array(
      '#type' => 'regex',
      '#value' => '[\\s\\(]theme_get_function\\s*\\(',
      '#warning_callback' => '_coder_6x_theme_get_function_warning',
    ),
  );
  $review = array(
    '#title' => t('Converting 5.x modules to 6.x'),
    '#link' => 'http://drupal.org/node/114774',
    '#rules' => $rules,
    '#severity' => 'critical',
  );
  return array(
    'upgrade6x' => $review,
  );
}