Title: PHP Fatal error
Last modified: March 24, 2022

---

# PHP Fatal error

 *  Resolved [magicoders](https://wordpress.org/support/users/patopaiar/)
 * (@patopaiar)
 * [4 years ago](https://wordpress.org/support/topic/php-fatal-error-294/)
 * Hi guys,
 * This ticket is a request for you to introduce a change described below, to avoid
   an `PHP Fatal error: Uncaught Error: Call to a member function enqueue() on null`
   that a site with this plugin enabled was experiencing and needed fixing.
 * There are a few threads going around reporting the same error, with replies mostly
   being that you are not able to reproduce.
 * With this site, I could reproduce it, and I think I have figured it out.
 * FYI, the error happens when trying to Add or Edit Pages from the backend specifically,
   and results in a WSOD and users completely unable to access their existing Pages
   or adding New Pages when this plugin is enabled.
 * This is what I have tracked it down to:
 * In the file `sensei-certificates\classes\class-woothemes-sensei-certificates.
   php`, on lines 109 to 111 in you have this code:
 *     ```
       if ( class_exists( 'Sensei_Assets' ) ) {
       	$instance->assets = new \Sensei_Assets( $instance->plugin_url, dirname( __DIR__ ), SENSEI_CERTIFICATES_VERSION );
       }
       ```
   
 * This ends up causing the Fatal Error on sites that have older versions of Sensei,
   where the class **Sensei_Assets** does not exist, and `$instance->assets` is 
   left undefined, as there is no `else` setting it.
 * When in the function **enqueue_block_editor_assets** this code attempts calling
   it like so
 *     ```
       WooThemes_Sensei_Certificates::instance()->assets->enqueue(
        'sensei-certificates-block',
        'blocks/index.js'
       );
       ```
   
 * This results in Fatal Error:
 *     ```
       PHP Fatal error:  Uncaught Error: Call to a member function enqueue() on null in path-to-site\wp-content\plugins\sensei-certificates\classes\class-woothemes-sensei-certificates.php:1472
       Stack trace:
       #0 path-to-site\wp-includes\class-wp-hook.php(307): WooThemes_Sensei_Certificates->enqueue_block_editor_assets('')
       #1 path-to-site\wp-includes\class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
       #2 path-to-site\wp-includes\plugin.php(474): WP_Hook->do_action(Array)
       #3 path-to-site\wp-admin\edit-form-blocks.php(265): do_action('enqueue_block_e...')
       #4 path-to-site\wp-admin\post-new.php(72): require('C:\\wamp74\\www\\s...')
       #5 {main}
         thrown in path-to-site\wp-content\plugins\sensei-certificates\classes\class-woothemes-sensei-certificates.php on line 1472
       ```
   
 * A possible fix, which you can apply as is to at least prevent a Fatal Error that
   brings down sites entirely, is to update the function to check the assets are
   set and bail early if they are not like so
 *     ```
       **
        * Enqueue block assets for the editing interface.
        *
        * @access private
        */
       public function enqueue_block_editor_assets() {
         $screen = get_current_screen();
   
         if( !WooThemes_Sensei_Certificates::instance()->assets ){
             return;
         }
   
         if ( $screen && 'page' === $screen->post_type ) { 
          WooThemes_Sensei_Certificates::instance()->assets->enqueue(
          'sensei-certificates-block',
          'blocks/index.js'
         );
         }
        }
       ```
   
 * Granted, this I imagine from scanning the code quickly would leave the Certificates
   block unavailable in the Block Editor, but it definitely beats a server error,
   no?
 * If you could please let me know if it will be possible for you to incorporate
   this change, would greatly appreciate it.
 * Any questions, happy to help.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Gaurav](https://wordpress.org/support/users/gaurav984/)
 * (@gaurav984)
 * [4 years ago](https://wordpress.org/support/topic/php-fatal-error-294/#post-15494863)
 * Hi there,
 * Thanks for reaching out and sharing your findings with us. I have submitted this
   as a bug report to our developers here
 * [https://github.com/woocommerce/sensei-certificates/issues/295](https://github.com/woocommerce/sensei-certificates/issues/295)
 * You can check the progress of the report and follow along with the development
   on the Github Repo.
 * Thanks again for the thorough investigation and for sharing your findings, we
   really appreciate it.
 * Please feel free to reach back out if you have any other questions.
 *  Thread Starter [magicoders](https://wordpress.org/support/users/patopaiar/)
 * (@patopaiar)
 * [4 years ago](https://wordpress.org/support/topic/php-fatal-error-294/#post-15495280)
 * Awesome! Thank you so much, really appreciate it from this end as well 🙂
 *  [Gaurav](https://wordpress.org/support/users/gaurav984/)
 * (@gaurav984)
 * [4 years ago](https://wordpress.org/support/topic/php-fatal-error-294/#post-15495399)
 * You are welcome!! Please feel free to contact us if you have any other questions.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Fatal error’ is closed to new replies.

 * ![](https://ps.w.org/sensei-certificates/assets/icon-256x256.png?rev=2531144)
 * [Sensei LMS Certificates](https://wordpress.org/plugins/sensei-certificates/)
 * [Support Threads](https://wordpress.org/support/plugin/sensei-certificates/)
 * [Active Topics](https://wordpress.org/support/plugin/sensei-certificates/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sensei-certificates/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sensei-certificates/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Gaurav](https://wordpress.org/support/users/gaurav984/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/php-fatal-error-294/#post-15495399)
 * Status: resolved