• I have a Custom Logger that tracks reordering the sticky posts. And I started getting this after updating to the version 4.2, and I thought it could be that someone has reported this, but I’m still getting it after updating to the version 4.2.1.

    Fatal error: Uncaught Error: Call to a member function get_events_table_name() on null
    in xxxxx/public/wp-content/plugins/simple-history/loggers/class-logger.php on line 95
    
    Call stack:
    
    Simple_History\Loggers\Logger::__construct()
    wp-content/themes/xxxxx/sticky-helper.php:131
    Sticky::order()
    wp-content/themes/xxxxx.php:239
    {closure}()
    wp-includes/class-wp-hook.php:308
    WP_Hook::apply_filters()
    wp-includes/plugin.php:256
    apply_filters_ref_array()
    wp-content/plugins/meta-box/inc/field.php:573
    RWMB_Field::filter()
    wp-content/plugins/meta-box/inc/meta-box.php:261
    RW_Meta_Box::save_field()
    array_map()
    wp-content/plugins/meta-box/inc/meta-box.php:241
    RW_Meta_Box::save_post()
    wp-content/plugins/meta-box-aio/vendor/meta-box/mb-settings-page/src/MetaBox.php:54
    MBSP\MetaBox::load()
    wp-includes/class-wp-hook.php:308
    WP_Hook::apply_filters()
    wp-includes/class-wp-hook.php:332
    WP_Hook::do_action()
    wp-includes/plugin.php:517
    do_action()
    wp-content/plugins/meta-box-aio/vendor/meta-box/mb-settings-page/src/SettingsPage.php:219
    MBSP\SettingsPage::load()
    wp-includes/class-wp-hook.php:308
    WP_Hook::apply_filters()
    wp-includes/class-wp-hook.php:332
    WP_Hook::do_action()
    wp-includes/plugin.php:517
    do_action()
    wp-admin/admin.php:237
    require_once()
    wp-admin/edit.php:10
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author eskapism

    (@eskapism)

    Thanks for the bug report. Any chance you could show the source code for your logger, so I can see and try the code myself?

    Thread Starter abazeed

    (@abazeed)

    Here’s the custom logger I’m using. I’m getting the error when a new instance of the class is created:

    add_action('simple_history/add_custom_logger', function ($simpleHistory) {
        $simpleHistory->register_logger('SimpleStickyLogger');
    });
    
    include_once WP_PLUGIN_DIR . '/simple-history/loggers/class-simple-logger.php';
    
    /**
     * Class for logging all sticky post changes.
    */
    class CustomLogger extends SimpleLogger {
    
        public $slug = 'SimpleLogger';
    
        /**
         * Return information about this logger.
         * Used to show info about the logger at various places.
         */
        public function getInfo() {
            $arr_info = array(
                'name'        => 'SimpleStickyLogger',
                'description' => 'Logs the changes of the sticky posts status and order',
                'capability'  => 'edit_pages',
                'messages'    => [
                    'sticky_post_added'     => '<b>Sticky Posts:</b> New sticky post is added - </br> {added_id}',
                    'sticky_post_removed'   => '<b>Sticky Posts:</b> One sticky post is removed by - {removed_id} {removed_link} [was sticky for {spent_time} ]"',
                    'sticky_post_replaced'  => '<b>Sticky Posts:</b> The following sticky post(s) are added: </br> {added_post_ids} </br> In the place of the following sticky posts:</br> {removed_post_ids} ',
                    'sticky_post_reordered' => '<b>Sticky Post:</b> The order of the sticky posts list item is updated: </br> {sticky_order} ',
                ],
                'labels' => [
                    'search' => [
                        'label'     => 'Sticky posts',
                        'label_all' => 'All sticky posts activity',
                        'options'   => [
                            'Sticky post added',
                            'Sticky post removed',
                            'Sticky post replaced',
                            'Sticky posts reordered',
                        ],
                    ],
                ],
            );
            return $arr_info;
        }
    
        function stickyOrderUpdated( $keyContent ) {
        SimpleLogger()->info( 'The order of the sticky posts list item is updated: {sticky_order}', $keyContent );
        }
    
        function stickyPostReplaced( $keyContent ) {
            SimpleLogger()->info( 'New sticky added {added_post_ids} replaced by {removed_post_ids} ', $keyContent );
        }
    
        function stickyPostAdded( $keyContent ) {
            SimpleLogger()->info( 'New sticky post {added_id} is added by {user_id}', $keyContent );
        }
    
        function stickyPostRemoved( $keyContent ) {
            SimplLogger()->info( 'Sticky post {removed_id} removed by {user_id}', $keyContent );
        }
    
        function videoAdded( $keyContent ) {
            SimpleLogger()->info( 'New video {added_id} is added by {user_id}', $keyContent );
        }
    
        function videoUpdated( $keyContent ) {
            SimpleLogger()->info( 'A video {updated_id} was updated by {user_id}. The following details were changed :<br> {detailed_content}', $keyContent );
        }
    
        function videoRemoved( $keyContent ) {
            SimpleLogger()->info( 'Video {removed_id} removed by {user_id} from {type}', $keyContent );
        }
    }
    Plugin Author eskapism

    (@eskapism)

    Could you try to extend Simple_History\Loggers\Logger instead of SimpleLogger and see if that helps?

    Also, make sure the slug of your logger is something unique, like “StickyPostsLogger”.

    If the above does not help then post your full code again and I’ll have another look.

    • This reply was modified 1 year, 4 months ago by eskapism.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Uncaught Error: Call to a member function get_events_table_name() on null’ is closed to new replies.