Support » Plugin: Helpful » Errors constantly being generated by Helpful

  • Resolved ubcsecurity

    (@ubcsecurity)


    Greetings Pixelbart.

    I am getting a constant influx of PHP errors and warnings that seem to be generated by the Helpful plugin. I have included the error messages below:

    **************
    PHP Warning: Invalid argument supplied for foreach() in /html.ssl/wp-content/plugins/helpful/core/classes/class-helpful-table.php on line 75, referer: /
    PHP Stack trace:, referer: /
    PHP 1. {main}() /html.ssl/wp-admin/admin-ajax.php:0, referer: /
    PHP 2. require_once() /html.ssl/wp-admin/admin-ajax.php:22, referer: /
    PHP 3. require_once() /html.ssl/wp-load.php:37, referer: /
    PHP 4. require_once() /html.ssl/wp-config.php:113, referer: /
    PHP 5. do_action() /html.ssl/wp-settings.php:394, referer: /
    PHP 6. WP_Hook->do_action() /html.ssl/wp-includes/plugin.php:465, referer: /
    PHP 7. WP_Hook->apply_filters() /html.ssl/wp-includes/class-wp-hook.php:310, referer: /
    PHP 8. call_user_func_array:{/html.ssl/wp-includes/class-wp-hook.php:286}() /html.ssl/wp-includes/class-wp-hook.php:286, referer: /
    PHP 9. {closure:/html.ssl/wp-content/plugins/helpful/core/autoload.php:61-63}() /html.ssl/wp-includes/class-wp-hook.php:286, referer: /
    PHP 10. Helpful_Table::get_instance() /html.ssl/wp-content/plugins/helpful/core/autoload.php:62, referer: /
    PHP 11. Helpful_Table->__construct() /html.ssl/wp-content/plugins/helpful/core/classes/class-helpful-table.php:25, referer: /
    PHP 12. Helpful_Table->registerColumnsContent() /html.ssl/wp-content/plugins/helpful/core/classes/class-helpful-table.php:12, referer: /

    PHP Warning: Invalid argument supplied for foreach() in /html.ssl/wp-content/plugins/helpful/core/classes/class-helpful-table.php on line 40, referer: /wp-admin/post.php?post=****&action=edit
    PHP Stack trace:, referer: /wp-admin/post.php?post=****&action=edit
    PHP 1. {main}() /html.ssl/wp-admin/admin-ajax.php:0, referer: /wp-admin/post.php?post=****&action=edit
    PHP 2. require_once() /html.ssl/wp-admin/admin-ajax.php:22, referer: /wp-admin/post.php?post=****&action=edit
    PHP 3. require_once() /html.ssl/wp-load.php:37, referer: /wp-admin/post.php?post=****&action=edit
    PHP 4. require_once() /html.ssl/wp-config.php:113, referer: /wp-admin/post.php?post=****&action=edit
    PHP 5. do_action() /html.ssl/wp-settings.php:394, referer: /wp-admin/post.php?post=****&action=edit
    PHP 6. WP_Hook->do_action() /html.ssl/wp-includes/plugin.php:465, referer: /wp-admin/post.php?post=****&action=edit
    PHP 7. WP_Hook->apply_filters() /html.ssl/wp-includes/class-wp-hook.php:310, referer: /wp-admin/post.php?post=****&action=edit
    PHP 8. call_user_func_array:{/html.ssl/wp-includes/class-wp-hook.php:286}() /html.ssl/wp-includes/class-wp-hook.php:286, referer: /wp-admin/post.php?post=****&action=edit
    PHP 9. {closure:/html.ssl/wp-content/plugins/helpful/core/autoload.php:61-63}() /html.ssl/wp-includes/class-wp-hook.php:286, referer: /wp-admin/post.php?post=****&action=edit
    PHP 10. Helpful_Table::get_instance() /html.ssl/wp-content/plugins/helpful/core/autoload.php:62, referer: /wp-admin/post.php?post=****&action=edit
    PHP 11. Helpful_Table->__construct() /html.ssl/wp-content/plugins/helpful/core/classes/class-helpful-table.php:25, referer: /wp-admin/post.php?post=****&action=edit
    PHP 12. Helpful_Table->registerColumns() /html.ssl/wp-content/plugins/helpful/core/classes/class-helpful-table.php:11, referer: /wp-admin/post.php?post=****&action=edit

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Pixelbart

    (@pixelbart)

    @ubcsecurity I’ll look into it later in the day. Thanks for your feedback!

    Which PHP version do you use?

    EDIT: Should be fixed with 4.0.3

    • This reply was modified 2 months, 3 weeks ago by  Pixelbart.

    I will check out 4.0.3 and let you know.

    Running PHP 5.4.16

    @pixelbart I am still getting flooded with these errors in my log file.

    Warning: Invalid argument supplied for foreach() in /wp-content/plugins/helpful/core/classes/class-helpful-table.php on line 40, referer: https:///wp-admin/index.php
    Stack trace:, referer: https:///wp-admin/index.php
    1. {main}() /wp-admin/admin-ajax.php:0, referer: https:///wp-admin/index.php
    2. require_once() /wp-admin/admin-ajax.php:22, referer: https:///wp-admin/index.php
    3. require_once() /wp-load.php:37, referer: https:///wp-admin/index.php
    4. require_once() /wp-config.php:113, referer: https:///wp-admin/index.php
    5. do_action() /wp-settings.php:394, referer: https:///wp-admin/index.php
    6. WP_Hook->do_action() /wp-includes/plugin.php:465, referer: https:///wp-admin/index.php
    7. WP_Hook->apply_filters() /wp-includes/class-wp-hook.php:310, referer: https:///wp-admin/index.php
    8. call_user_func_array:{/wp-includes/class-wp-hook.php:286}() /wp-includes/class-wp-hook.php:286, referer: https:///wp-admin/index.php
    9. {closure:/wp-content/plugins/helpful/core/autoload.php:62-64}() /wp-includes/class-wp-hook.php:286, referer: https:///wp-admin/index.php
    10. Helpful_Table::get_instance() /wp-content/plugins/helpful/core/autoload.php:63, referer: https:///wp-admin/index.php
    11. Helpful_Table->__construct() /wp-content/plugins/helpful/core/classes/class-helpful-table.php:25, referer: https:///wp-admin/index.php
    12. Helpful_Table->registerColumns() /wp-content/plugins/helpful/core/classes/class-helpful-table.php:11, referer: https:///wp-admin/index.php
    Warning: Invalid argument supplied for foreach() in /wp-content/plugins/helpful/core/classes/class-helpful-table.php on line 76, referer: https:///wp-admin/index.php
    Stack trace:, referer: https:///wp-admin/index.php
    1. {main}() /wp-admin/admin-ajax.php:0, referer: https:///wp-admin/index.php
    2. require_once() /wp-admin/admin-ajax.php:22, referer: https:///wp-admin/index.php
    3. require_once() /wp-load.php:37, referer: https:///wp-admin/index.php
    4. require_once() /wp-config.php:113, referer: https:///wp-admin/index.php
    5. do_action() /wp-settings.php:394, referer: https:///wp-admin/index.php
    6. WP_Hook->do_action() /wp-includes/plugin.php:465, referer: https:///wp-admin/index.php
    7. WP_Hook->apply_filters() /wp-includes/class-wp-hook.php:310, referer: https:///wp-admin/index.php
    8. call_user_func_array:{/wp-includes/class-wp-hook.php:286}() /wp-includes/class-wp-hook.php:286, referer: https:///wp-admin/index.php
    9. {closure:/wp-content/plugins/helpful/core/autoload.php:62-64}() /wp-includes/class-wp-hook.php:286, referer: https:///wp-admin/index.php
    10. Helpful_Table::get_instance() /wp-content/plugins/helpful/core/autoload.php:63, referer: https:///wp-admin/index.php
    11. Helpful_Table->__construct() /wp-content/plugins/helpful/core/classes/class-helpful-table.php:25, referer: https:///wp-admin/index.php
    12. Helpful_Table->registerColumnsContent() /wp-content/plugins/helpful/core/classes/class-helpful-table.php:12, referer: https:///wp-admin/index.php

    Okay so I took a look at your code, and have a number of fixes.

    1. /core/classes/class-helpful-shortcodes.php – public function addToContent($content)

    global $post;
    
    $post_types = get_option('helpful_post_types');
    
    $user_id = Helpful_Helper_Values::getUser();
    
    if ( !is_array ( $post_types ) || !in_array ( $post->post_type, $post_types ) ) {
    
        return $content;
          
    }

    2. /core/classes/class-helpful-table.php – public function registerColumns()

    $post_types = get_option( 'helpful_post_types' );
    
    if( !isset ( $post_types ) || !is_array ( $post_types ) ) {
        
        return;
        
    }
        
    foreach( $post_types as $post_type ) {
    
        $post_type = esc_attr( $post_type );
    
        add_filter( 'manage_edit-' . $post_type . '_columns', [ $this, 'setColumnsTitle' ], 10 );
    
    }
    • This reply was modified 2 months, 3 weeks ago by  ubcsecurity.
    • This reply was modified 2 months, 3 weeks ago by  ubcsecurity.
    • This reply was modified 2 months, 3 weeks ago by  ubcsecurity.

    @pixelbart

    Also, getting a lot of errors because the table “helpful_feedback” has not been created, and this is throwing errors on the wp-admin dashboard when viewing the Helpful widget, as well as when someone tries to submit feedback.

    WordPress database error Table ‘wp_helpful_feedback’ doesn’t exist for query SELECT * FROM wp_helpful_feedback ORDER BY time DESC LIMIT 5 made by wp_dashboard, do_meta_boxes, call_user_func, Helpful_Widget->widgetCallback, Helpful_Widget->renderTemplate, include_once(‘/plugins/helpful/templates/admin-widget.php’), Helpful_Helper_Feedback::getFeedbackItems

    WordPress database error Table ‘wp_helpful_feedback’ doesn’t exist for query SHOW FULL COLUMNS FROM wp_helpful_feedback made by do_action(‘wp_ajax_helpful_save_feedback’), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, Helpful_Frontend->saveFeedback, Helpful_Helper_Feedback::insertFeedback

    Plugin Author Pixelbart

    (@pixelbart)

    @ubcsecurity

    I can’t reproduce these errors and other users don’t seem to have these errors either. WordPress itself now needs a higher version.

    Since I can’t support every PHP version and always try to program safely, I use more recent versions.

    I fixed the error with the table and also the checks of the post type array, as you can see in your example. There it is correctly queried if it is an array.

    The database table is created automatically when performing maintenance or updating the plugin.

    If you have such problems with the plugin, you are welcome to try other plugins. I don’t force anyone to use my plugin here.

    If you come up with solutions for your case, please feel free to tell me. Personally I don’t see any mistakes there.

    Nevertheless as always: Thank you for your feedback!

    Hi @pixelbart.

    I don’t think this has anything to do with PHP versions. I have updated to the latest version, and am still getting flooded with errors.

    Just to be clear, the examples I included above were my suggestions on how to address the errors. In the file core/classes/helpful-class-shortcodes.php, on line 51 specifically:

    I suggest changing the line from:

    if (!in_array($post->post_type, $post_types)) {

    to:

    if (!is_array($post_types) || !in_array($post->post_type, $post_types)) {

    the reason being is that because the helpful_post_types object is not always set, and you are not checking it. The function “in_array” expects an array parameter…

    I saw that you included my second suggestion in the class-helpful-table.php file, so no more errors from there.

    I am still however getting the same errors when viewing the admin dashboard widget, or trying to save feedback when someone chooses the contra option for a post:

    [Tue Jul 02 16:24:10.573550 2019] [:error] [pid 21248] [client ] WordPress database error Table ‘wp_helpful_feedback’ doesn’t exist for query SELECT * FROM wp_helpful_feedback ORDER BY time DESC LIMIT 5 made by wp_dashboard, do_meta_boxes, call_user_func, Helpful_Widget->widgetCallback, Helpful_Widget->renderTemplate, include_once(‘/plugins/helpful/templates/admin-widget.php’), Helpful_Helper_Feedback::getFeedbackItems, referer: /

    [Tue Jul 02 16:30:30.829622 2019] [:error] [pid 20968] [client ] WordPress database error Table ‘wp_helpful_feedback’ doesn’t exist for query SHOW FULL COLUMNS FROM wp_helpful_feedback made by do_action(‘wp_ajax_helpful_save_feedback’), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, Helpful_Frontend->saveFeedback, Helpful_Helper_Feedback::insertFeedback, referer: /

    Cheers.

    Plugin Author Pixelbart

    (@pixelbart)

    @ubcsecurity

    Thanks for the details. That’s right, I have to ask again if the array is set. I will still do it!

    The one with the table is solved in one of the versions. You have to go to Helpful Settings -> System and do the maintenance there once. Helpful will do the rest for you.

    4.0.8

    – The maintenance procedure in the Helpful settings, which can be found there under System, now also checks whether the database tables exist and creates them if they do not exist.
    – FAQ updated

    Plugin Author Pixelbart

    (@pixelbart)

    @ubcsecurity This should be fixed with version 4.0.10 for you. If I forgot another array and you notice something, feel free to comment again!

    Many thanks for your help!

    Hi @pixelbart

    Everything is working great now. Thanks for pointing me to the maintenance button, that cleared up the missing database table. No more errors! Thanks!

    Plugin Author Pixelbart

    (@pixelbart)

    @ubcsecurity That’s great to hear! I’m happy that Helpful is running with you now. If there is anything else, just let me know again.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.