function coder_6x_reviews in Coder 6.2
Same name and namespace in other branches
- 5.2 includes/coder_6x.inc \coder_6x_reviews()
- 5 includes/coder_6x.inc \coder_6x_reviews()
- 6 includes/coder_6x.inc \coder_6x_reviews()
Implementation of hook_reviews().
File
- includes/
coder_6x.inc, line 11 - 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',
'#function' => '_menu$',
'#value' => '(for|foreach|while)\\s*\\(',
'#warning_callback' => '_coder_6x_new_menu_loop_warning',
),
array(
'#type' => 'regex',
'#function' => '_menu$',
'#value' => '[\'"]access callback.*=.*\\(',
'#source' => 'allphp',
'#warning_callback' => '_coder_6x_menu_access_callback_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\\s*\\((' . $argex . '\\s*,\\s*){3,}(' . $argex . ')\\s*\\)',
'#warning_callback' => '_coder_6x_url_l_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]url\\s*\\((' . $argex . '\\s*,\\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_save|taxonomy_node_delete)\\s*\\(\\s*(\\d+|\\$(nid|node->nid))',
'#warning_callback' => '_coder_6x_taxonomy_node_get_terms_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]strtr\\s*\\(\\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*([\'"]|\\$table)',
'#warning_callback' => '_coder_6x_cache_set_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]cache_set\\s*\\(\\s*[^\\)]+,\\s*serialize\\s*\\(\\s*',
'#warning_callback' => '_coder_6x_cache_serialize_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]unserialize\\s*\\(\\s*cache_get\\s*\\(',
'#warning_callback' => '_coder_6x_cache_serialize_warning',
),
array(
'#type' => 'regex',
'#value' => '\\$_SERVER\\s*\\[\\s*[\'"]REMOTE_ADDR[\'"]\\s*\\]',
'#source' => 'allphp',
'#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' => '[\\s\\(]file_save_upload\\s*\\([^,]+\\s*,\\s*(\\$dest|\\$destination|\'\'|"")\\s*',
'#never' => 'function file_save_upload',
'#warning_callback' => '_coder_6x_file_save_upload_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#value' => '\\{file_revisions\\}',
'#warning' => 'The {' . 'file_revisions} table is now {upload}',
),
array(
'#type' => 'callback',
'#value' => '_coder_6x_callback',
// @NOTE: This is not used. It only exists to catch potential errors in this code.
'#warning_callback' => '_coder_6x_callback_warning',
),
// FAPI Rules.
array(
'#type' => 'regex',
'#source' => 'allphp',
'#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' => 'allphp',
'#value' => '\\$form\\s*\\[\\s*[\'"]#validate[\'"]\\]\\[[\'"]',
'#warning_callback' => '_coder_6x_formapi_element_validate_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#function' => '_elements$',
'#value' => '\\s*[\'"]#validate[\'"]\\s*=>\\s*',
'#warning_callback' => '_coder_6x_formapi_element_validate_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#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' => '_(validate|submit)\\s*\\(\\s*\\$form\\s*,\\s*\\$form_state\\s*\\)[^;]',
'#warning_callback' => '_coder_6x_form_validate_and_submit_warning',
),
array(
'#type' => 'regex',
'#value' => '_(prerender)\\s*\\(\\s*\\$form_id',
'#warning_callback' => '_coder_6x_form_prerender_warning',
),
array(
'#type' => 'regex',
'#value' => '\\$form\\[[\'"]#submit[\'"]\\]\\[[\'"]',
'#source' => 'allphp',
'#warning_callback' => '_coder_6x_formapi_custom_params_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]form_set_value\\s*\\([^,]+(,\\s*[^,\\)]+){0,1}\\)',
'#warning_callback' => '_coder_6x_form_set_value_warning',
'#not' => 'array\\s*\\(',
),
/* 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' => 'function\\s+[a-z0-9_]+_(help)\\s*\\(\\s*[^,]+\\)',
'#warning_callback' => '_coder_6x_hook_help_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#value' => '\\$form(_values)?\\s*\\[\\s*[\'"]?op[\'"]?\\s*\\]',
'#warning' => 'replace $form[\'op\'] with $form_state[\'values\'][\'op\']',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#function' => '_(un)?install$|_update_[0-9]+$',
'#value' => '\\$GLOBALS\\[[\'"]?db_type[\'"]?\\]',
'#warning_callback' => '_coder_6x_schema_api_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#function' => '_submit$|_validate$',
'#value' => '\\$form(_values)?\\[[\'"][A-Za-z]',
'#never' => '[\\s\\(]form_error\\(',
'#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',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]db_num_rows\\s*\\(',
'#warning_callback' => '_coder_6x_db_num_rows_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]drupal_retrieve_form\\s*\\(' . $argex . '\\s*\\)',
'#warning_callback' => '_coder_6x_drupal_retrieve_form_warning',
),
array(
'#type' => 'regex',
'#function' => '_menu$',
'#value' => 'node\\/add\\/',
'#source' => 'all',
'#warning_callback' => '_coder_6x_menu_node_add_warning',
),
array(
'#type' => 'regex',
'#value' => 'variable_(get|set|del)\\(\\s*[\'"]comment_form_location[\'"]\\s*(,|\\))',
'#source' => 'allphp',
'#warning_callback' => '_coder_6x_comment_form_location_warning',
),
array(
'#type' => 'regex',
'#value' => '=\\s*[\'"]comment_form_location[\'"]\\s*;',
'#source' => 'allphp',
'#warning_callback' => '_coder_6x_comment_form_location_warning',
),
array(
'#type' => 'regex',
'#value' => 'admin\\/content\\/comment\\/settings',
'#source' => 'quote',
'#warning_callback' => '_coder_6x_comment_form_location_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]node_access_rebuild\\s*\\(',
'#function' => '_disable$|_enable$',
'#warning_callback' => '_coder_6x_node_access_rebuild_warning',
),
array(
'#type' => 'regex',
'#value' => 'admin\\/logs',
'#source' => 'all',
'#warning_callback' => '_coder_6x_admin_logs_warning',
),
array(
'#type' => 'regex',
'#value' => 'user_access\\s*\\(\\s*\'\\s*administer\\s+access\\s+control\\s*\'\\s*\\)|admin\\/user\\/access',
'#source' => 'all',
'#warning_callback' => '_coder_6x_administer_access_control_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#value' => '(\\$form\\s*\\[\\s*[\'"]#DANGEROUS_SKIP_CHECK[\'"]|[\'"]#DANGEROUS_SKIP_CHECK[\'"]\\s*=>)',
'#warning_callback' => '_coder_6x_dangerous_skip_check_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]locale_refresh_cache\\s*\\(',
'#warning_callback' => '_coder_6x_locale_refresh_cache_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]db_next_id\\s*\\(',
'#warning_callback' => '_coder_6x_db_next_id_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]menu_set_location\\s*\\(',
'#warning_callback' => '_coder_6x_menu_set_location_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]taxonomy_get_vocabulary\\s*\\(',
'#warning_callback' => '_coder_6x_taxonomy_get_vocabulary_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]db_result\\s*\\((' . $argex . ')\\s*,\\s*' . $argex . '\\);$',
'#warning_callback' => '_coder_6x_db_result_warning',
),
array(
'#type' => 'regex',
'#value' => 'watchdog\\s*\\(\\s*[\'"]debug[\'"]\\s*,\\s*',
'#source' => 'allphp',
'#warning_callback' => '_coder_6x_watchdog_debug_warning',
),
// Book module rules - start.
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_admin_orphan\\s*\\(',
'#warning_callback' => '_coder_6x_book_admin_orphan_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_content\\s*\\(',
'#warning_callback' => '_coder_6x_book_content_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_form\\s*\\(',
'#warning_callback' => '_coder_6x_book_form_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_insert\\s*\\(',
'#warning_callback' => '_coder_6x_book_insert_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_location\\s*\\(',
'#warning_callback' => '_coder_6x_book_location_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_location_down\\s*\\(',
'#warning_callback' => '_coder_6x_book_location_down_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_node_visitor_html_post\\s*\\(',
'#warning_callback' => '_coder_6x_book_node_visitor_html_post_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_node_visitor_html_pre\\s*\\(',
'#warning_callback' => '_coder_6x_book_node_visitor_html_pre_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_recurse\\s*\\(',
'#warning_callback' => '_coder_6x_book_recurse_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_toc_recurse\\s*\\(',
'#warning_callback' => '_coder_6x_book_toc_recurse_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_tree\\s*\\(',
'#warning_callback' => '_coder_6x_book_tree_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_tree_recurse\\s*\\(',
'#warning_callback' => '_coder_6x_book_tree_recurse_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_admin_edit\\s*\\((' . $argex . '\\s*)\\)',
'#warning_callback' => '_coder_6x_book_admin_edit_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(](book_toc\\s*\\((' . $argex . '\\s*)\\)|book_toc\\s*\\(\\s*\\))',
'#warning_callback' => '_coder_6x_book_toc_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_export_html\\s*\\((' . $argex . '\\s*,\\s*)',
'#warning_callback' => '_coder_6x_book_export_html_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(](book_export\\s*\\((' . $argex . '\\s*)\\)|book_export\\s*\\(\\s*\\))',
'#warning_callback' => '_coder_6x_book_export_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_outline\\s*\\(\\$(nid|node->nid)',
'#warning_callback' => '_coder_6x_book_outline_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_prev\\s*\\(\\$node',
'#warning_callback' => '_coder_6x_book_prev_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]book_next\\s*\\(\\$node',
'#warning_callback' => '_coder_6x_book_next_warning',
),
// Book module rules - end.
array(
'#type' => 'regex',
'#value' => '\\s*[\'"]#value[\'"]\\s*=>\\s*t\\s*\\(\\s*[\'"]Submit[\'"]\\s*\\)',
'#source' => 'allphp',
'#warning' => 'When labelling buttons, make it clear what the button does, "Submit" is too generic.',
'#severity' => 'minor',
),
array(
'#type' => 'regex',
'#function' => '_nodeapi$',
'#source' => 'allphp',
'#value' => '(case\\s+[\'"]submit[\'"]\\s*:)|(==\\s*[\'"]submit[\'"])',
'#warning_callback' => '_coder_6x_nodeapi_submit_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#value' => '[\\s\\(]drupal_mail\\s*\\(\\s*[^,]+,\\s*(\\$to|\\$recipient|\\$[a-zA-Z_]+?\\->mail|(\'|").+@.+(\'|"))',
'#warning_callback' => '_coder_6x_drupal_mail_warning',
),
array(
'#type' => 'regex',
'#value' => '^(create\\s+table\\s+|alter\\s+table\\s+|drop\\s+table\\s+)',
'#source' => 'quote',
'#warning_callback' => '_coder_6x_drupal_install_schema_warning',
),
array(
'#type' => 'regex',
'#value' => '[\\s\\(]user_authenticate\\s*\\((' . $argex . '\\s*,\\s*)(' . $argex . ')\\s*\\)',
'#warning_callback' => '_coder_6x_user_authenticate_warning',
),
array(
'#type' => 'regex',
'#value' => 'function\\s+[a-z0-9_]+_(access)\\s*\\((' . $argex . '\\s*,\\s*)(' . $argex . ')\\s*\\)',
'#warning_callback' => '_coder_6x_hook_access_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#value' => '(node|user|menu|menu_link|taxonomy_vocabulary|contact|filter_format|forum_term|aggregator_feed|aggregator_category)_load\\(arg\\([0-9]\\)\\)',
'#warning_callback' => '_coder_6x_menu_get_object_warning',
),
array(
'#type' => 'regex',
'#function' => '_submit$',
'#value' => '\\s+return\\s+(' . $argex . ');',
'#warning_callback' => '_coder_6x_form_submit_warning',
),
array(
'#type' => 'regex',
'#function' => '_menu$',
'#source' => 'allphp',
'#value' => '\'title\'\\s*=>\\s*t\\(|\'description\'\\s*=>\\s*t\\(',
'#warning_callback' => '_coder_6x_menu_localization_warning',
),
array(
'#type' => 'regex',
'#value' => 'function\\s+[a-z0-9_]+_(forms)\\s*\\(\\s*[^,]+\\)',
'#warning_callback' => '_coder_6x_hook_forms_warning',
),
array(
'#type' => 'regex',
'#source' => 'allphp',
'#value' => '\\$form\\s*\\[\\s*[\'"]#pre_render[\'"]\\s*\\]\\[\\s*[\'"].*[\'"]\\s*\\]\\s*=',
'#warning_callback' => '_coder_6x_formapi_prerender_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,
);
}