• Resolved Lucas Stark

    (@lucasstark)


    I’m unable to query the WP REST API when WP_DEBUG is active due to a series of warnings.

    It seems that most of the warnings are coming from the Custom Tables class.

    The warning is:
    Notice: Trying to get property ‘meta’ of non-object in /app/public/wp-content/plugins/gamipress/libraries/ct/includes/class-ct-rest-meta-fields.php on line 59.

    Upon debug inspection I found that the table name is never being passed to the CT_REST_Meta_Fields class and will always result in that error.

    I attempted to resolve by setting the table name to that inside of the CT_REST_Controller class in the __constructor, however that resulted in fatal errors in other parts of the gamification plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Lucas Stark

    (@lucasstark)

    This is the code causing the warning:

    
      protected function get_meta_type() {
            return $this->table->meta->name;
        }
    

    Inside of the CT_REST_Meta_Fields class.

    Plugin Author Ruben Garcia

    (@rubengc)

    Hi @lucasstark

    Thank you so much for your report

    We just introduced a fix for this issue for the next release

    Meanwhile, to let you continue working with WP_DEBUG enabled you can:
    1 – Setup WordPress to log errors instead of render them by adding following line to your wp-config.php:

    
    define( 'WP_DEBUG_LOG', true );
    

    2 – Manually fix the issue, simply override the __construct() function of our CT_REST_Meta_Fields class with the next code:

        public function __construct( $name ) {
            $this->name = $name;
            $this->table = ct_get_table_object( $name );
    
        }

    Best regards

    • This reply was modified 4 years, 4 months ago by Ruben Garcia.
    • This reply was modified 4 years, 4 months ago by Ruben Garcia.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Errors and Warnings in Latest Version’ is closed to new replies.