Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to migrate connector to Stream 3 #783

Closed
nebbens opened this issue Oct 20, 2015 · 7 comments
Closed

Unable to migrate connector to Stream 3 #783

nebbens opened this issue Oct 20, 2015 · 7 comments

Comments

@nebbens
Copy link

nebbens commented Oct 20, 2015

I am trying to upgrade our custom connector to STREAM 3, but am experiencing some issues. On the STREAM log page it says "class wasn't loaded because it doesn't implement the get_label method." However our connector does implement the get_label method and I have checked it against some of the other connectors and that method seems correct.
The other issue that is likely related is that I notice the functions have now all been changed to non-static. Is it possible to see an example of the usage of these now?
Thank you,
Natalie

@lukecarbis
Copy link
Contributor

Hi Natalie,

You're right - this error is probably occurring because you're implementing get_label in a static way.

I've updated our documentation with an example of how to correctly implement a connector in Stream 3.0. You can see it here: https://github.com/xwp/stream/wiki/Creating-a-Custom-Connector

Let me know if there's anything more I can do to help!

@nebbens
Copy link
Author

nebbens commented Oct 21, 2015

Thank you for your response and for the update to the wiki! I actually had removed the references to static in all of the function calls, so I'm not sure why it wasn't seeing the get_label implementation, but after playing around a bit, I have a new error.

Fatal error: Call to a member function get_label() on a non-object in /home/pefisrae/public_html/wp-content/plugins/stream/classes/class-connectors.php on line 115

I assume this is because the functions are no longer static and so I need to change how I am initiating the calls to our STREAM connector. Previously I was using:

do_action( 'pef_notifications_import', 'Gift', $filename, 'Completed' );

where Gift, filename & Completed were parameters to my callback function.
Thank you for any assistance you can give.

@lukecarbis
Copy link
Contributor

That error looks like you're not adding your class correctly via the filter. See the Registering A Connector part in the docs: https://github.com/xwp/stream/wiki/Creating-a-Custom-Connector#registering-a-connector

If you're confident that it's being registered correctly, then could you please edit classes/class-connectors.php, and search for this code:

/**
 * Allows for adding additional connectors via classes that extend Connector.
 *
 * @param array $classes An array of Connector objects.
 */
$this->connectors = apply_filters( 'wp_stream_connectors', $classes );

Immediately below this, add:

var_dump( $this->connectors );
die();

Refresh Stream and paste your results here.

@nebbens
Copy link
Author

nebbens commented Oct 22, 2015

Thank you, Luke. It appears to be putting the plugin name into the array rather than an instance of the plugin. (see last array object)

array(14) { [0]=> object(WP_Stream\Connector_Blogs)#54 (4) { ["name"]=> string(5) "blogs" ["actions"]=> array(14) { [0]=> string(13) "wpmu_new_blog" [1]=> string(18) "wpmu_activate_blog" [2]=> string(13) "wpmu_new_user" [3]=> string(16) "add_user_to_blog" [4]=> string(21) "remove_user_from_blog" [5]=> string(14) "make_spam_blog" [6]=> string(13) "make_ham_blog" [7]=> string(11) "mature_blog" [8]=> string(13) "unmature_blog" [9]=> string(12) "archive_blog" [10]=> string(14) "unarchive_blog" [11]=> string(16) "make_delete_blog" [12]=> string(18) "make_undelete_blog" [13]=> string(18) "update_blog_public" } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [1]=> object(WP_Stream\Connector_Comments)#55 (5) { ["name"]=> string(8) "comments" ["actions"]=> array(12) { [0]=> string(21) "comment_flood_trigger" [1]=> string(17) "wp_insert_comment" [2]=> string(12) "edit_comment" [3]=> string(18) "before_delete_post" [4]=> string(12) "deleted_post" [5]=> string(14) "delete_comment" [6]=> string(13) "trash_comment" [7]=> string(15) "untrash_comment" [8]=> string(12) "spam_comment" [9]=> string(14) "unspam_comment" [10]=> string(25) "transition_comment_status" [11]=> string(25) "comment_duplicate_trigger" } ["delete_post":protected]=> int(0) ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [2]=> object(WP_Stream\Connector_Editor)#56 (5) { ["name"]=> string(6) "editor" ["actions"]=> array(0) { } ["edited_file":"WP_Stream\Connector_Editor":private]=> array(0) { } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [3]=> object(WP_Stream\Connector_Installer)#57 (4) { ["name"]=> string(9) "installer" ["actions"]=> array(8) { [0]=> string(25) "upgrader_process_complete" [1]=> string(15) "activate_plugin" [2]=> string(17) "deactivate_plugin" [3]=> string(12) "switch_theme" [4]=> string(35) "delete_site_transient_update_themes" [5]=> string(28) "pre_option_uninstall_plugins" [6]=> string(37) "pre_set_site_transient_update_plugins" [7]=> string(26) "_core_updated_successfully" } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [4]=> object(WP_Stream\Connector_Media)#58 (4) { ["name"]=> string(5) "media" ["actions"]=> array(5) { [0]=> string(14) "add_attachment" [1]=> string(15) "edit_attachment" [2]=> string(17) "delete_attachment" [3]=> string(25) "wp_save_image_editor_file" [4]=> string(18) "wp_save_image_file" } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [5]=> object(WP_Stream\Connector_Menus)#59 (4) { ["name"]=> string(5) "menus" ["actions"]=> array(3) { [0]=> string(18) "wp_create_nav_menu" [1]=> string(18) "wp_update_nav_menu" [2]=> string(15) "delete_nav_menu" } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [6]=> object(WP_Stream\Connector_Posts)#60 (4) { ["name"]=> string(5) "posts" ["actions"]=> array(2) { [0]=> string(22) "transition_post_status" [1]=> string(12) "deleted_post" } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [7]=> object(WP_Stream\Connector_Settings)#61 (6) { ["name"]=> string(8) "settings" ["actions"]=> array(5) { [0]=> string(17) "whitelist_options" [1]=> string(18) "update_site_option" [2]=> string(33) "update_option_permalink_structure" [3]=> string(27) "update_option_category_base" [4]=> string(22) "update_option_tag_base" } ["permalink_options"]=> array(3) { [0]=> string(19) "permalink_structure" [1]=> string(13) "category_base" [2]=> string(8) "tag_base" } ["network_options"]=> array(25) { [0]=> string(24) "registrationnotification" [1]=> string(12) "registration" [2]=> string(13) "add_new_users" [3]=> string(10) "menu_items" [4]=> string(27) "upload_space_check_disabled" [5]=> string(17) "blog_upload_space" [6]=> string(16) "upload_filetypes" [7]=> string(9) "site_name" [8]=> string(10) "first_post" [9]=> string(10) "first_page" [10]=> string(13) "first_comment" [11]=> string(17) "first_comment_url" [12]=> string(20) "first_comment_author" [13]=> string(13) "welcome_email" [14]=> string(18) "welcome_user_email" [15]=> string(15) "fileupload_maxk" [16]=> string(20) "global_terms_enabled" [17]=> string(13) "illegal_names" [18]=> string(21) "limited_email_domains" [19]=> string(20) "banned_email_domains" [20]=> string(6) "WPLANG" [21]=> string(10) "blog_count" [22]=> string(10) "user_count" [23]=> string(11) "admin_email" [24]=> string(15) "new_admin_email" } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [8]=> object(WP_Stream\Connector_Taxonomies)#53 (6) { ["name"]=> string(10) "taxonomies" ["actions"]=> array(4) { [0]=> string(12) "created_term" [1]=> string(11) "delete_term" [2]=> string(9) "edit_term" [3]=> string(11) "edited_term" } ["cached_term_before_update"]=> NULL ["context_labels"]=> NULL ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [9]=> object(WP_Stream\Connector_Users)#52 (5) { ["name"]=> string(5) "users" ["_users_object_pre_deleted":protected]=> array(0) { } ["actions"]=> array(9) { [0]=> string(13) "user_register" [1]=> string(14) "profile_update" [2]=> string(14) "password_reset" [3]=> string(17) "retrieve_password" [4]=> string(20) "set_logged_in_cookie" [5]=> string(17) "clear_auth_cookie" [6]=> string(11) "delete_user" [7]=> string(12) "deleted_user" [8]=> string(13) "set_user_role" } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [10]=> object(WP_Stream\Connector_Widgets)#51 (6) { ["verbose_widget_created_deleted_actions"]=> bool(false) ["name"]=> string(7) "widgets" ["actions"]=> array(2) { [0]=> string(30) "update_option_sidebars_widgets" [1]=> string(14) "updated_option" } ["customizer_initial_sidebars_widgets":protected]=> NULL ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [11]=> object(WP_Stream\Connector_ACF)#50 (6) { ["name"]=> string(3) "acf" ["actions"]=> array(10) { [0]=> string(15) "added_post_meta" [1]=> string(17) "updated_post_meta" [2]=> string(16) "delete_post_meta" [3]=> string(15) "added_user_meta" [4]=> string(17) "updated_user_meta" [5]=> string(16) "delete_user_meta" [6]=> string(12) "added_option" [7]=> string(14) "updated_option" [8]=> string(14) "deleted_option" [9]=> string(15) "pre_post_update" } ["cached_location_rules"]=> array(0) { } ["cached_field_values_updates"]=> array(0) { } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [12]=> object(WP_Stream\Connector_GravityForms)#48 (6) { ["name"]=> string(12) "gravityforms" ["actions"]=> array(28) { [0]=> string(21) "gform_after_save_form" [1]=> string(27) "gform_pre_confirmation_save" [2]=> string(27) "gform_pre_notification_save" [3]=> string(25) "gform_notification_delete" [4]=> string(25) "gform_confirmation_delete" [5]=> string(25) "gform_notification_status" [6]=> string(25) "gform_confirmation_status" [7]=> string(24) "gform_form_status_change" [8]=> string(22) "gform_form_reset_views" [9]=> string(24) "gform_before_delete_form" [10]=> string(16) "gform_form_trash" [11]=> string(18) "gform_form_restore" [12]=> string(20) "gform_form_duplicate" [13]=> string(22) "gform_export_separator" [14]=> string(20) "gform_export_options" [15]=> string(29) "gform_import_form_xml_options" [16]=> string(17) "gform_delete_lead" [17]=> string(17) "gform_insert_note" [18]=> string(17) "gform_delete_note" [19]=> string(19) "gform_update_status" [20]=> string(20) "gform_update_is_read" [21]=> string(23) "gform_update_is_starred" [22]=> string(13) "update_option" [23]=> string(10) "add_option" [24]=> string(13) "delete_option" [25]=> string(18) "update_site_option" [26]=> string(15) "add_site_option" [27]=> string(18) "delete_site_option" } ["options"]=> array(0) { } ["options_override"]=> array(0) { } ["delayed"]=> array(0) { } ["prev_stream"]=> NULL } [13]=> string(37) "WP_Stream_Connector_PEF_Notifications" }

@nebbens
Copy link
Author

nebbens commented Oct 22, 2015

Here is my registration code:
function pef_register_stream_connector( $classes ) {

            require_once( PEF_CLASS_PATH . 'class-stream-connector.php');
            $classes[] = 'WP_Stream_Connector_PEF_Notifications'; // The name of your child class

            return $classes;
        }
        add_filter( 'wp_stream_connectors', 'pef_register_stream_connector' );

@lukecarbis
Copy link
Contributor

@nebbens Yeah - you're spot on. You need to supply the instantiated class. I've updated the docs to reflect that.

https://github.com/xwp/stream/wiki/Creating-a-Custom-Connector#registering-a-connector

@nebbens
Copy link
Author

nebbens commented Oct 22, 2015

Thank you again, Luke. That fixed things. I saw that was how you were handling the other connectors, just wasn't sure where to get the log, etc. Thank you for updating the documentation--much easier!
One note though that it needs a ; on the line $stream = wp_stream_get_instance().
Thank you for the quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants