Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding sniffer for Elgg 1.7 and 1.8 deprecations.

  • Loading branch information...
commit 3a06eef34dfdaa01f6a95a9a58d759fc94d2cf1f 1 parent 7969966
mikehedman authored

Showing 1 changed file with 208 additions and 0 deletions. Show diff stats Hide diff stats

  1. +208 0 Sniffs/PHP/DeprecatedFunctionsSniff.php
208 Sniffs/PHP/DeprecatedFunctionsSniff.php
... ... @@ -0,0 +1,208 @@
  1 +<?php
  2 +/**
  3 + * Elgg_Sniffs_PHP_DeprecatedFunctionsSniff
  4 + *
  5 + * @category PHP
  6 + * @package Elgg
  7 + * @author Mike Hedman
  8 + */
  9 +class Elgg_Sniffs_PHP_DeprecatedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
  10 +{
  11 +
  12 + /**
  13 + * A list of forbidden functions with their alternatives.
  14 + *
  15 + * The value is NULL if no alternative exists. IE, the
  16 + * function should just not be used.
  17 + *
  18 + * @var array(string => string|null)
  19 + */
  20 + protected $forbiddenFunctions = array(
  21 + //deprecations from \engine\lib\deprecated-1.7.php
  22 + 'get_entities_from_access_id' => 'Use elgg_get_entities_from_access_id()',
  23 + 'get_entities_from_access_collection' => 'deprecated by elgg_get_entities()',
  24 + 'get_entities_from_annotations' => 'Use elgg_get_entities_from_annotations()',
  25 + 'list_entities_from_annotations' => 'Use elgg_list_entities_from_annotations()',
  26 + 'get_library_files' => 'Use elgg_get_file_list() instead',
  27 + 'elgg_validate_action_url' => 'final',
  28 + 'test_ip' => null,
  29 + 'is_ip_in_array' => null,
  30 + 'get_entities' => ' Use elgg_get_entities().',
  31 + 'delete_entities' => 'This is a dangerous function as it defaults to deleting everything.',
  32 + 'list_registered_entities' => ' Use elgg_list_registered_entities().',
  33 + 'list_entities' => ' Use elgg_list_entities().',
  34 + 'search_for_group' => 'Deprecated by new search plugin.',
  35 + 'search_list_groups_by_name' => 'deprecated by new search plugin',
  36 + 'list_group_search' => 'deprecated by new search plugin',
  37 + 'get_entities_from_metadata' => 'use elgg_get_entities_from_metadata().',
  38 + 'get_entities_from_metadata_multi' => ' Use elgg_get_entities_from_metadata().',
  39 + 'menu_item' => 'deprecated by add_submenu_item',
  40 + 'search_for_object' => 'deprecated by new search plugin',
  41 + 'search_list_objects_by_name' => 'deprecated by new search plugin',
  42 + 'get_entities_from_relationship' => 'Use elgg_get_entities_from_relationship()',
  43 + 'search_for_site' => 'deprecated by new search plugin',
  44 + 'search_for_user' => 'deprecated by new search plugin',
  45 + 'list_user_search' => 'deprecated by new search plugin',
  46 + 'search_list_users_by_name' => 'deprecated by new search plugin',
  47 + 'extend_view' => ' Use elgg_extend_view().',
  48 + 'get_views' => ' Use elgg_get_views().',
  49 + 'make_register_object' => 'Use {@link add_submenu_item()}',
  50 + 'delete_object_entity' => null,
  51 + 'delete_user_entity' => null,
  52 +
  53 + //deprecations from \engine\lib\deprecated-1.8.php
  54 + 'db_upgrade' => 'Use PHP upgrades for sql changes.',
  55 + 'list_entities_from_access_id' => 'Use elgg_list_entities_from_access_id()',
  56 + 'register_action' => 'Use {@link elgg_register_action()} instead',
  57 + 'extend_elgg_admin_page' => 'Extend admin views manually',
  58 + 'get_entities_from_annotations_calculate_x' => 'Use elgg_get_entities_from_annotation_calculation()',
  59 + 'get_entities_from_annotation_count' => 'Use elgg_get_entities_from_annotation_calculation()',
  60 + 'list_entities_from_annotation_count' => 'Use elgg_list_entities_from_annotation_calculation()',
  61 + 'add_to_register' => 'Use the new menu system.',
  62 + 'remove_from_register' => 'Use the new menu system.',
  63 + 'get_register' => 'Use the new menu system',
  64 + 'events' => 'Use explicit register/trigger event functions',
  65 + 'register_elgg_event_handler' => 'Use elgg_register_event_handler() instead',
  66 + 'unregister_elgg_event_handler' => 'Use elgg_unregister_event_handler instead',
  67 + 'trigger_elgg_event' => 'Use elgg_trigger_event() instead',
  68 + 'register_plugin_hook' => 'Use elgg_register_plugin_hook_handler() instead',
  69 + 'unregister_plugin_hook' => 'Use elgg_unregister_plugin_hook_handler() instead',
  70 + 'trigger_plugin_hook' => 'Use elgg_trigger_plugin_hook() instead',
  71 + 'call_gatekeeper' => 'A neat but pointless function',
  72 + 'callpath_gatekeeper' => 'A neat but pointless function',
  73 + 'elgg_get_entity_owner_where_sql' => 'Use elgg_get_guid_based_where_sql();',
  74 + 'elgg_get_entity_container_where_sql' => 'Use elgg_get_guid_based_where_sql();',
  75 + 'elgg_get_entity_site_where_sql' => 'Use elgg_get_guid_based_where_sql()',
  76 + 'get_objects_in_group' => 'Use elgg_get_entities() instead',
  77 + 'list_entities_groups' => 'Use elgg_list_entities() instead',
  78 + 'get_entities_from_metadata_groups' => 'Use elgg_get_entities_from_metadata()',
  79 + 'get_entities_from_metadata_groups_multi' => 'Use elgg_get_entities_from_metadata()',
  80 + 'list_entities_in_area' => 'Use elgg_get_entities_from_location()',
  81 + 'list_entities_location' => 'Use elgg_list_entities_from_location()',
  82 + 'get_entities_in_area' => 'Use elgg_get_entities_from_location()',
  83 + 'list_entities_from_metadata' => 'Use elgg_list_entities_from_metadata',
  84 + 'list_entities_from_metadata_multi' => 'Use elgg_list_entities_from_metadata() instead',
  85 + 'add_submenu_item' => 'Use the new menu system',
  86 + 'remove_submenu_item' => 'Use the new menu system',
  87 + 'get_submenu' => 'Use the new menu system. elgg_view_menu()',
  88 + 'add_menu' => 'use elgg_register_menu_item() for the menu \'site\'',
  89 + 'remove_menu' => 'Use the new menu system',
  90 + 'friendly_title' => 'Use elgg_get_friendly_title()',
  91 + 'friendly_time' => 'Use elgg_view_friendly_time()',
  92 + 'filter_string' => 'Don\'t use this.',
  93 + 'remove_blacklist' => 'Don\'t use this.',
  94 + 'page_owner' => ' Use elgg_get_page_owner_guid()',
  95 + 'page_owner_entity' => ' Use elgg_get_page_owner_entity()',
  96 + 'add_page_owner_handler' => ' Use the \'page_owner\', \'system\' plugin hook',
  97 + 'set_page_owner' => ' Use elgg_set_page_owner_guid()',
  98 + 'set_context' => ' Use elgg_set_context()',
  99 + 'get_context' => ' Use elgg_get_context()',
  100 + 'get_plugin_list' => 'Use elgg_get_plugin_ids_in_dir() or elgg_get_plugins()',
  101 + 'regenerate_plugin_list' => 'Use elgg_generate_plugin_entities() and elgg_set_plugin_priorities()',
  102 + 'get_plugin_name' => 'Use elgg_get_calling_plugin_id()',
  103 + 'load_plugin_manifest' => 'Use ElggPlugin->getManifest()',
  104 + 'check_plugin_compatibility' => 'Use ElggPlugin->canActivate()',
  105 + 'find_plugin_settings' => 'Use elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()',
  106 + 'get_installed_plugins' => 'use elgg_get_plugins()',
  107 + 'enable_plugin' => 'Use ElggPlugin->activate()',
  108 + 'disable_plugin' => 'Use ElggPlugin->deactivate()',
  109 + 'is_plugin_enabled' => 'Use elgg_is_active_plugin()',
  110 + 'get_entities_from_private_setting' => 'Use elgg_get_entities_from_private_settings()',
  111 + 'get_entities_from_private_setting_multi' => 'Use elgg_get_entities_from_private_settings()',
  112 + 'list_entities_from_relationship' => 'Use elgg_list_entities_from_relationship()',
  113 + 'get_entities_by_relationship_count' => 'Use elgg_get_entities_from_relationship_count()',
  114 + 'list_entities_by_relationship_count' => 'Use elgg_list_entities_from_relationship_count()',
  115 + 'get_entities_from_relationships_and_meta' => 'Use elgg_get_entities_from_relationship()',
  116 + 'get_river_items' => 'Use elgg_get_river()',
  117 + 'elgg_view_river_items' => 'Use elgg_list_river()',
  118 + 'get_activity_stream_data' => 'This is outdated and uses the systemlog table instead of the river table.',
  119 + 'authenticate' => 'Use elgg_authenticate',
  120 + 'get_site_members' => 'Use ElggSite::getMembers()',
  121 + 'list_site_members' => 'Use ElggSite::listMembers()',
  122 + 'add_site_collection' => 'Don\'t use this.',
  123 + 'remove_site_collection' => 'Don\'t use this.',
  124 + 'get_site_collections' => 'Don\'t use this.',
  125 + 'get_tags' => ' Use elgg_get_tags().',
  126 + 'display_tagcloud' => 'use elgg_view_tagcloud()',
  127 + 'get_user_objects' => 'Use elgg_get_entities() instead',
  128 + 'count_user_objects' => 'Use elgg_get_entities() instead',
  129 + 'list_user_objects' => 'Use elgg_list_entities() instead',
  130 + 'get_user_objects_by_metadata' => 'Use elgg_get_entities_from_metadata() instead',
  131 + 'set_user_validation_status' => 'Use elgg_set_user_validation_status()',
  132 + 'request_user_validation' => 'Hook into the register, user plugin hook and request validation.',
  133 + 'extend_elgg_settings_page' => 'Extend one of the views in core/settings',
  134 + 'page_draw' => 'Use elgg_view_page()',
  135 + 'elgg_view_listing' => 'use elgg_view_image_block()',
  136 + 'get_entity_icon_url' => 'Use $entity->getIconURL()',
  137 + 'get_loggedin_user' => 'Use elgg_get_logged_in_user_entity()',
  138 + 'get_loggedin_userid' => 'Use elgg_get_logged_in_user_guid()',
  139 + 'isloggedin' => 'Use elgg_is_logged_in();',
  140 + 'isadminloggedin' => 'Use elgg_is_admin_logged_in()',
  141 + 'load_plugins' => 'Use elgg_load_plugins()',
  142 + 'find_plugin_usersettings' => 'Use elgg_get_all_plugin_user_settings() or ElggPlugin->getAllUserSettings()',
  143 + 'set_plugin_usersetting' => 'Use elgg_set_plugin_user_setting() or ElggPlugin->setUserSetting()',
  144 + 'clear_plugin_usersetting' => 'Use elgg_unset_plugin_user_setting or ElggPlugin->unsetUserSetting().',
  145 + 'get_plugin_usersetting' => 'Use elgg_get_plugin_user_setting() or ElggPlugin->getUserSetting()',
  146 + 'set_plugin_setting' => 'Use elgg_set_plugin_setting() or ElggPlugin->setSetting()',
  147 + 'get_plugin_setting' => 'Use elgg_get_plugin_setting() or ElggPlugin->getSetting()',
  148 + 'clear_plugin_setting' => 'Use elgg_unset_plugin_setting() or ElggPlugin->unsetSetting()',
  149 + 'clear_all_plugin_settings' => 'Use elgg_unset_all_plugin_settings() or ElggPlugin->unsetAllSettings()',
  150 + 'get_annotations' => 'Use elgg_get_annotations()',
  151 + 'list_annotations' => 'Use elgg_list_annotations()',
  152 + 'elgg_deprecated_annotation_calculation' => null,
  153 + 'count_annotations' => 'Use elgg_get_annotations() and pass \'count\' => true',
  154 + 'get_annotations_sum' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'sum\'',
  155 + 'get_annotations_max' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'max\'',
  156 + 'get_annotations_min' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'min\'',
  157 + 'get_annotations_avg' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'min\'',
  158 + 'get_annotations_calculate_x' => 'Use elgg_get_annotations() and pass anntoation_calculation => ',
  159 + 'list_entities_from_annotation_count_by_metadata' => 'Use elgg_list_entities_from_annotation_calculation().',
  160 + 'set_view_location' => 'Use elgg_set_view_location()',
  161 + 'register_entity_url_handler' => 'Use elgg_register_entity_url_handler()',
  162 + 'find_metadata' => 'Use elgg_get_metadata()',
  163 + 'get_metadata_byname' => 'Use elgg_get_metadata()',
  164 + 'get_metadata_for_entity' => 'Use elgg_get_metadata()',
  165 + 'get_metadata' => 'Use elgg_get_metadata_from_id()',
  166 + 'clear_metadata' => 'Use elgg_delete_metadata()',
  167 + 'clear_metadata_by_owner' => 'Use elgg_delete_metadata()',
  168 + 'delete_metadata' => 'Use elgg_delete_metadata()',
  169 + 'remove_metadata' => 'Use elgg_delete_metadata()',
  170 + 'get_annotation' => 'Use elgg_get_annotation_from_id()',
  171 + 'delete_annotation' => 'Use elgg_delete_annotations()',
  172 + 'clear_annotations' => 'Use elgg_delete_annotations()',
  173 + 'clear_annotations_by_owner' => 'Use elgg_delete_annotations()',
  174 + 'register_page_handler' => 'Use {@link elgg_register_page_handler()}',
  175 + 'unregister_page_handler' => 'Use {@link elgg_unregister_page_handler()}',
  176 + 'register_annotation_url_handler' => 'Use {@link elgg_register_annotation_url_handler()}',
  177 + 'register_extender_url_handler' => 'Use {@link elgg_register_extender_url_handler()}',
  178 + 'register_entity_type' => 'Use {@link elgg_register_entity_type()}',
  179 + 'register_metadata_url_handler' => 'Use {@link elgg_register_metadata_url_handler()}',
  180 + 'register_relationship_url_handler' => 'Use {@link elgg_register_relationship_url_handler()}',
  181 + 'elgg_view_register_simplecache' => 'Use {@link elgg_register_simplecache_view()}',
  182 + 'elgg_view_regenerate_simplecache' => 'Use {@link elgg_regenerate_simplecache()}',
  183 + 'elgg_view_enable_simplecache' => 'Use {@link elgg_enable_simplecache()}',
  184 + 'elgg_view_disable_simplecache' => 'Use {@link elgg_disable_simplecache()}',
  185 + 'is_db_installed' => null,
  186 + 'is_installed' => null,
  187 + 'pam_authenticate' => 'See {@link ElggPAM}',
  188 + 'save_widget_location' => 'use ElggWidget::move()',
  189 + 'get_widgets' => 'Use elgg_get_widgets()',
  190 + 'add_widget' => 'use elgg_create_widget()',
  191 + 'add_widget_type' => 'Use elgg_register_widget_type',
  192 + 'remove_widget_type' => 'Use elgg_unregister_widget_type',
  193 + 'widget_type_exists' => 'Use elgg_is_widget_type',
  194 + 'get_widget_types' => 'Use elgg_get_widget_types',
  195 + 'save_widget_info' => 'Use elgg_save_widget_settings',
  196 + 'reorder_widgets_from_panel' => 'Don\'t use.',
  197 + 'use_widgets' => 'Don\'t use.',
  198 + 'using_widgets' => 'Don\'t use.',
  199 + 'display_widget' => 'Use elgg_view_entity()',
  200 + 'elgg_count_comments' => 'Use ElggEntity->countComments()',
  201 + 'remove_from_river_by_subject' => 'Use elgg_delete_river()',
  202 + 'remove_from_river_by_object' => 'Use elgg_delete_river()',
  203 + 'remove_from_river_by_annotation' => 'Use elgg_delete_river()',
  204 + 'remove_from_river_by_id' => 'Use elgg_delete_river()',
  205 + 'default_page_handler' => null
  206 + );
  207 +
  208 +}//end class

0 comments on commit 3a06eef

Please sign in to comment.
Something went wrong with that request. Please try again.