Skip to content
Browse files

Adding sniffer for Elgg 1.7 and 1.8 deprecations.

  • Loading branch information...
1 parent 7969966 commit 3a06eef34dfdaa01f6a95a9a58d759fc94d2cf1f @mikehedman committed Mar 18, 2012
Showing with 208 additions and 0 deletions.
  1. +208 −0 Sniffs/PHP/DeprecatedFunctionsSniff.php
View
208 Sniffs/PHP/DeprecatedFunctionsSniff.php
@@ -0,0 +1,208 @@
+<?php
+/**
+ * Elgg_Sniffs_PHP_DeprecatedFunctionsSniff
+ *
+ * @category PHP
+ * @package Elgg
+ * @author Mike Hedman
+ */
+class Elgg_Sniffs_PHP_DeprecatedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
+{
+
+ /**
+ * A list of forbidden functions with their alternatives.
+ *
+ * The value is NULL if no alternative exists. IE, the
+ * function should just not be used.
+ *
+ * @var array(string => string|null)
+ */
+ protected $forbiddenFunctions = array(
+ //deprecations from \engine\lib\deprecated-1.7.php
+ 'get_entities_from_access_id' => 'Use elgg_get_entities_from_access_id()',
+ 'get_entities_from_access_collection' => 'deprecated by elgg_get_entities()',
+ 'get_entities_from_annotations' => 'Use elgg_get_entities_from_annotations()',
+ 'list_entities_from_annotations' => 'Use elgg_list_entities_from_annotations()',
+ 'get_library_files' => 'Use elgg_get_file_list() instead',
+ 'elgg_validate_action_url' => 'final',
+ 'test_ip' => null,
+ 'is_ip_in_array' => null,
+ 'get_entities' => ' Use elgg_get_entities().',
+ 'delete_entities' => 'This is a dangerous function as it defaults to deleting everything.',
+ 'list_registered_entities' => ' Use elgg_list_registered_entities().',
+ 'list_entities' => ' Use elgg_list_entities().',
+ 'search_for_group' => 'Deprecated by new search plugin.',
+ 'search_list_groups_by_name' => 'deprecated by new search plugin',
+ 'list_group_search' => 'deprecated by new search plugin',
+ 'get_entities_from_metadata' => 'use elgg_get_entities_from_metadata().',
+ 'get_entities_from_metadata_multi' => ' Use elgg_get_entities_from_metadata().',
+ 'menu_item' => 'deprecated by add_submenu_item',
+ 'search_for_object' => 'deprecated by new search plugin',
+ 'search_list_objects_by_name' => 'deprecated by new search plugin',
+ 'get_entities_from_relationship' => 'Use elgg_get_entities_from_relationship()',
+ 'search_for_site' => 'deprecated by new search plugin',
+ 'search_for_user' => 'deprecated by new search plugin',
+ 'list_user_search' => 'deprecated by new search plugin',
+ 'search_list_users_by_name' => 'deprecated by new search plugin',
+ 'extend_view' => ' Use elgg_extend_view().',
+ 'get_views' => ' Use elgg_get_views().',
+ 'make_register_object' => 'Use {@link add_submenu_item()}',
+ 'delete_object_entity' => null,
+ 'delete_user_entity' => null,
+
+ //deprecations from \engine\lib\deprecated-1.8.php
+ 'db_upgrade' => 'Use PHP upgrades for sql changes.',
+ 'list_entities_from_access_id' => 'Use elgg_list_entities_from_access_id()',
+ 'register_action' => 'Use {@link elgg_register_action()} instead',
+ 'extend_elgg_admin_page' => 'Extend admin views manually',
+ 'get_entities_from_annotations_calculate_x' => 'Use elgg_get_entities_from_annotation_calculation()',
+ 'get_entities_from_annotation_count' => 'Use elgg_get_entities_from_annotation_calculation()',
+ 'list_entities_from_annotation_count' => 'Use elgg_list_entities_from_annotation_calculation()',
+ 'add_to_register' => 'Use the new menu system.',
+ 'remove_from_register' => 'Use the new menu system.',
+ 'get_register' => 'Use the new menu system',
+ 'events' => 'Use explicit register/trigger event functions',
+ 'register_elgg_event_handler' => 'Use elgg_register_event_handler() instead',
+ 'unregister_elgg_event_handler' => 'Use elgg_unregister_event_handler instead',
+ 'trigger_elgg_event' => 'Use elgg_trigger_event() instead',
+ 'register_plugin_hook' => 'Use elgg_register_plugin_hook_handler() instead',
+ 'unregister_plugin_hook' => 'Use elgg_unregister_plugin_hook_handler() instead',
+ 'trigger_plugin_hook' => 'Use elgg_trigger_plugin_hook() instead',
+ 'call_gatekeeper' => 'A neat but pointless function',
+ 'callpath_gatekeeper' => 'A neat but pointless function',
+ 'elgg_get_entity_owner_where_sql' => 'Use elgg_get_guid_based_where_sql();',
+ 'elgg_get_entity_container_where_sql' => 'Use elgg_get_guid_based_where_sql();',
+ 'elgg_get_entity_site_where_sql' => 'Use elgg_get_guid_based_where_sql()',
+ 'get_objects_in_group' => 'Use elgg_get_entities() instead',
+ 'list_entities_groups' => 'Use elgg_list_entities() instead',
+ 'get_entities_from_metadata_groups' => 'Use elgg_get_entities_from_metadata()',
+ 'get_entities_from_metadata_groups_multi' => 'Use elgg_get_entities_from_metadata()',
+ 'list_entities_in_area' => 'Use elgg_get_entities_from_location()',
+ 'list_entities_location' => 'Use elgg_list_entities_from_location()',
+ 'get_entities_in_area' => 'Use elgg_get_entities_from_location()',
+ 'list_entities_from_metadata' => 'Use elgg_list_entities_from_metadata',
+ 'list_entities_from_metadata_multi' => 'Use elgg_list_entities_from_metadata() instead',
+ 'add_submenu_item' => 'Use the new menu system',
+ 'remove_submenu_item' => 'Use the new menu system',
+ 'get_submenu' => 'Use the new menu system. elgg_view_menu()',
+ 'add_menu' => 'use elgg_register_menu_item() for the menu \'site\'',
+ 'remove_menu' => 'Use the new menu system',
+ 'friendly_title' => 'Use elgg_get_friendly_title()',
+ 'friendly_time' => 'Use elgg_view_friendly_time()',
+ 'filter_string' => 'Don\'t use this.',
+ 'remove_blacklist' => 'Don\'t use this.',
+ 'page_owner' => ' Use elgg_get_page_owner_guid()',
+ 'page_owner_entity' => ' Use elgg_get_page_owner_entity()',
+ 'add_page_owner_handler' => ' Use the \'page_owner\', \'system\' plugin hook',
+ 'set_page_owner' => ' Use elgg_set_page_owner_guid()',
+ 'set_context' => ' Use elgg_set_context()',
+ 'get_context' => ' Use elgg_get_context()',
+ 'get_plugin_list' => 'Use elgg_get_plugin_ids_in_dir() or elgg_get_plugins()',
+ 'regenerate_plugin_list' => 'Use elgg_generate_plugin_entities() and elgg_set_plugin_priorities()',
+ 'get_plugin_name' => 'Use elgg_get_calling_plugin_id()',
+ 'load_plugin_manifest' => 'Use ElggPlugin->getManifest()',
+ 'check_plugin_compatibility' => 'Use ElggPlugin->canActivate()',
+ 'find_plugin_settings' => 'Use elgg_get_calling_plugin_entity() or elgg_get_plugin_from_id()',
+ 'get_installed_plugins' => 'use elgg_get_plugins()',
+ 'enable_plugin' => 'Use ElggPlugin->activate()',
+ 'disable_plugin' => 'Use ElggPlugin->deactivate()',
+ 'is_plugin_enabled' => 'Use elgg_is_active_plugin()',
+ 'get_entities_from_private_setting' => 'Use elgg_get_entities_from_private_settings()',
+ 'get_entities_from_private_setting_multi' => 'Use elgg_get_entities_from_private_settings()',
+ 'list_entities_from_relationship' => 'Use elgg_list_entities_from_relationship()',
+ 'get_entities_by_relationship_count' => 'Use elgg_get_entities_from_relationship_count()',
+ 'list_entities_by_relationship_count' => 'Use elgg_list_entities_from_relationship_count()',
+ 'get_entities_from_relationships_and_meta' => 'Use elgg_get_entities_from_relationship()',
+ 'get_river_items' => 'Use elgg_get_river()',
+ 'elgg_view_river_items' => 'Use elgg_list_river()',
+ 'get_activity_stream_data' => 'This is outdated and uses the systemlog table instead of the river table.',
+ 'authenticate' => 'Use elgg_authenticate',
+ 'get_site_members' => 'Use ElggSite::getMembers()',
+ 'list_site_members' => 'Use ElggSite::listMembers()',
+ 'add_site_collection' => 'Don\'t use this.',
+ 'remove_site_collection' => 'Don\'t use this.',
+ 'get_site_collections' => 'Don\'t use this.',
+ 'get_tags' => ' Use elgg_get_tags().',
+ 'display_tagcloud' => 'use elgg_view_tagcloud()',
+ 'get_user_objects' => 'Use elgg_get_entities() instead',
+ 'count_user_objects' => 'Use elgg_get_entities() instead',
+ 'list_user_objects' => 'Use elgg_list_entities() instead',
+ 'get_user_objects_by_metadata' => 'Use elgg_get_entities_from_metadata() instead',
+ 'set_user_validation_status' => 'Use elgg_set_user_validation_status()',
+ 'request_user_validation' => 'Hook into the register, user plugin hook and request validation.',
+ 'extend_elgg_settings_page' => 'Extend one of the views in core/settings',
+ 'page_draw' => 'Use elgg_view_page()',
+ 'elgg_view_listing' => 'use elgg_view_image_block()',
+ 'get_entity_icon_url' => 'Use $entity->getIconURL()',
+ 'get_loggedin_user' => 'Use elgg_get_logged_in_user_entity()',
+ 'get_loggedin_userid' => 'Use elgg_get_logged_in_user_guid()',
+ 'isloggedin' => 'Use elgg_is_logged_in();',
+ 'isadminloggedin' => 'Use elgg_is_admin_logged_in()',
+ 'load_plugins' => 'Use elgg_load_plugins()',
+ 'find_plugin_usersettings' => 'Use elgg_get_all_plugin_user_settings() or ElggPlugin->getAllUserSettings()',
+ 'set_plugin_usersetting' => 'Use elgg_set_plugin_user_setting() or ElggPlugin->setUserSetting()',
+ 'clear_plugin_usersetting' => 'Use elgg_unset_plugin_user_setting or ElggPlugin->unsetUserSetting().',
+ 'get_plugin_usersetting' => 'Use elgg_get_plugin_user_setting() or ElggPlugin->getUserSetting()',
+ 'set_plugin_setting' => 'Use elgg_set_plugin_setting() or ElggPlugin->setSetting()',
+ 'get_plugin_setting' => 'Use elgg_get_plugin_setting() or ElggPlugin->getSetting()',
+ 'clear_plugin_setting' => 'Use elgg_unset_plugin_setting() or ElggPlugin->unsetSetting()',
+ 'clear_all_plugin_settings' => 'Use elgg_unset_all_plugin_settings() or ElggPlugin->unsetAllSettings()',
+ 'get_annotations' => 'Use elgg_get_annotations()',
+ 'list_annotations' => 'Use elgg_list_annotations()',
+ 'elgg_deprecated_annotation_calculation' => null,
+ 'count_annotations' => 'Use elgg_get_annotations() and pass \'count\' => true',
+ 'get_annotations_sum' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'sum\'',
+ 'get_annotations_max' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'max\'',
+ 'get_annotations_min' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'min\'',
+ 'get_annotations_avg' => 'Use elgg_get_annotations() and pass \'annotation_calculation\' => \'min\'',
+ 'get_annotations_calculate_x' => 'Use elgg_get_annotations() and pass anntoation_calculation => ',
+ 'list_entities_from_annotation_count_by_metadata' => 'Use elgg_list_entities_from_annotation_calculation().',
+ 'set_view_location' => 'Use elgg_set_view_location()',
+ 'register_entity_url_handler' => 'Use elgg_register_entity_url_handler()',
+ 'find_metadata' => 'Use elgg_get_metadata()',
+ 'get_metadata_byname' => 'Use elgg_get_metadata()',
+ 'get_metadata_for_entity' => 'Use elgg_get_metadata()',
+ 'get_metadata' => 'Use elgg_get_metadata_from_id()',
+ 'clear_metadata' => 'Use elgg_delete_metadata()',
+ 'clear_metadata_by_owner' => 'Use elgg_delete_metadata()',
+ 'delete_metadata' => 'Use elgg_delete_metadata()',
+ 'remove_metadata' => 'Use elgg_delete_metadata()',
+ 'get_annotation' => 'Use elgg_get_annotation_from_id()',
+ 'delete_annotation' => 'Use elgg_delete_annotations()',
+ 'clear_annotations' => 'Use elgg_delete_annotations()',
+ 'clear_annotations_by_owner' => 'Use elgg_delete_annotations()',
+ 'register_page_handler' => 'Use {@link elgg_register_page_handler()}',
+ 'unregister_page_handler' => 'Use {@link elgg_unregister_page_handler()}',
+ 'register_annotation_url_handler' => 'Use {@link elgg_register_annotation_url_handler()}',
+ 'register_extender_url_handler' => 'Use {@link elgg_register_extender_url_handler()}',
+ 'register_entity_type' => 'Use {@link elgg_register_entity_type()}',
+ 'register_metadata_url_handler' => 'Use {@link elgg_register_metadata_url_handler()}',
+ 'register_relationship_url_handler' => 'Use {@link elgg_register_relationship_url_handler()}',
+ 'elgg_view_register_simplecache' => 'Use {@link elgg_register_simplecache_view()}',
+ 'elgg_view_regenerate_simplecache' => 'Use {@link elgg_regenerate_simplecache()}',
+ 'elgg_view_enable_simplecache' => 'Use {@link elgg_enable_simplecache()}',
+ 'elgg_view_disable_simplecache' => 'Use {@link elgg_disable_simplecache()}',
+ 'is_db_installed' => null,
+ 'is_installed' => null,
+ 'pam_authenticate' => 'See {@link ElggPAM}',
+ 'save_widget_location' => 'use ElggWidget::move()',
+ 'get_widgets' => 'Use elgg_get_widgets()',
+ 'add_widget' => 'use elgg_create_widget()',
+ 'add_widget_type' => 'Use elgg_register_widget_type',
+ 'remove_widget_type' => 'Use elgg_unregister_widget_type',
+ 'widget_type_exists' => 'Use elgg_is_widget_type',
+ 'get_widget_types' => 'Use elgg_get_widget_types',
+ 'save_widget_info' => 'Use elgg_save_widget_settings',
+ 'reorder_widgets_from_panel' => 'Don\'t use.',
+ 'use_widgets' => 'Don\'t use.',
+ 'using_widgets' => 'Don\'t use.',
+ 'display_widget' => 'Use elgg_view_entity()',
+ 'elgg_count_comments' => 'Use ElggEntity->countComments()',
+ 'remove_from_river_by_subject' => 'Use elgg_delete_river()',
+ 'remove_from_river_by_object' => 'Use elgg_delete_river()',
+ 'remove_from_river_by_annotation' => 'Use elgg_delete_river()',
+ 'remove_from_river_by_id' => 'Use elgg_delete_river()',
+ 'default_page_handler' => null
+ );
+
+}//end class

0 comments on commit 3a06eef

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