Commit c21bcdb9 authored by Doug Green's avatar Doug Green
Browse files

more 6x upgrade rules

parent 99f2e9b6
Loading
Loading
Loading
Loading
+63 −4
Original line number Diff line number Diff line
@@ -137,6 +137,31 @@ function coder_6x_reviews() {
      '#value' => '[\s\(]form_set_value\s*\([^,]+(,\s*[^,\)]+){0,1}\)',
      '#warning_callback' => '_coder_6x_form_set_value_warning',
    ),
    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',
    ),
  );
  $review = array(
    '#title' => t('Converting 5.x modules to 6.x'),
@@ -316,6 +341,15 @@ function _coder_6x_file_check_upload_warning() {
  );
}

function _coder_6x_form_validate_and_submit_warning() {
  return t('The number of parameters for form !hook_validate and !hook_submit have changed',
    array(
      '!hook_validate' => theme('drupalapi', 'hook_validate'),
      '!hook_submit' => theme('drupalapi', 'hook_submit'),
    )
  );
}

function _coder_6x_form_set_value_warning() {
  return t('!form_set_value() parameters have changed',
    array(
@@ -324,11 +358,36 @@ function _coder_6x_form_set_value_warning() {
  );
}

function _coder_6x_form_validate_and_submit_warning() {
  return t('The number of parameters for form !hook_validate and !hook_submit have changed',
function _coder_6x_confirm_form_warning() {
  return t('The arguments to !confirm_form() have changed',
    array(
      '!hook_validate' => theme('drupalapi', 'hook_validate'),
      '!hook_submit' => theme('drupalapi', 'hook_submit'),
      '!confirm_form' => theme('drupalapi', 'confirm_form'),
    )
  );
}

function _coder_6x_custom_url_rewrite_warning() {
  return t('In place of !custom_url_rewrite, use !custom_url_rewrite_inbound() or !custom_url_rewrite_outbound()',
    array(
      '!custom_url_rewrite' => theme('drupalapi', 'custom_url_rewrite'),
      '!custom_url_rewrite_inbound' => theme('drupalapi', 'custom_url_rewrite_inbound'),
      '!custom_url_rewrite_outbound' => theme('drupalapi', 'custom_url_rewrite_outbound'),
    )
  );
}

function _coder_6x_hook_info_auth_warning() {
  return t('hook no longer exists, use !hook_form_alter() to swap your own validation handler',
    array(
      '!hook_form_alter' => theme('drupalapi', 'hook_form_alter'),
    )
  );
}

function _coder_6x_hook_help_warning() {
  return t('The arguments to !hook_help have changed',
    array(
      '!hook_help' => theme('drupalapi', 'hook_help'),
    )
  );
}
+20 −0
Original line number Diff line number Diff line
@@ -45,6 +45,14 @@ function _coder_6x_more_tests() {

  form_set_value($element, 'value', $form_status); // This one is okay
  form_set_value($element, 'value'); // error

  confirm_form($form, t('Do you really want to delete this?'), "node/$nid", t("Don't do it unless you're really sure!"), t('Delete it'), t('Go back'), 'delete'); // should fail

  confirm_form($form, t('Do you really want to delete this?'), "node/$nid", $options); // is ok
  confirm_form($form, t('Do you really want to delete this?'), "node/$nid", array()); // also ok

  custom_url_rewrite($url); // not ok
  custom_url_rewrite_inbound($url); // ok
}

function _coder_6x_test_link_alter($node, &$links) { // an error
@@ -70,3 +78,15 @@ function myform_submit($form_id, $form) { //this willfail
  $form['#submit']['newsubmit'] = array();
  $form['#submit'][] = "newsubmit";
}

function mymodule_info($field = 0) {
}

function mymodule_auth($username, $password, $server) {
}

function mymodule_help($section) {
}

function mymodule_help($section, $arg) { // ok
}