Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15
  1. #11
    Join Date
    Jul 2012
    Posts
    16,751
    Plugin Contributions
    17

    Default Re: PHP Fatal error: Call to a member function get_template_dir() on null in credit_c

    Quote Originally Posted by Jeff_Mash View Post
    This is what mine looks like (appears to be the same as yours):

    Code:
    function zen_debug_error_handler ($errno, $errstr, $errfile, $errline) {
      if (!(error_reporting() & $errno)) {
        return;
      }
      ob_start();
      if (version_compare(PHP_VERSION, '5.3.6') >= 0) {
        debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
      } else {
        debug_print_backtrace();
      }
      $backtrace = ob_get_contents();
      ob_end_clean();
      // The following line removes the call to this zen_debug_error_handler function (as it's not relevant)
      $backtrace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $backtrace, 1);  
      error_log('Request URI: ' . $_SERVER['REQUEST_URI'] . ', IP address: ' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'not set') . "\n" . $backtrace);
      
      return false;  // Let PHP's built-in error handler do its thing.
    }
    What about the remainder of the file? Any changes from a default version as found at: https://github.com/zencart/zencart/t...r_logging.php?

    If look at the version information found at the version link at the top of the admin screen, is ini_set disabled? Is the backtrace function disabled?

    As far as the "exact" times, log files can be expected to be generated as much as 5 minutes out from when the issue occurs. Yes, the white screen likely is from the error that is/was described considering it is actually an error not a warning or notice.

    If the log captured the debug backtrace information expected then would have more of the information that helps to track down the details of the problem. Who made the request, what software was aligned to get to that point, what the uri had, etc...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  2. #12
    Join Date
    Aug 2004
    Posts
    768
    Plugin Contributions
    0

    Default Re: PHP Fatal error: Call to a member function get_template_dir() on null in credit_c

    Quote Originally Posted by mc12345678 View Post
    What about the remainder of the file? Any changes from a default version as found at: https://github.com/zencart/zencart/t...r_logging.php?
    That link didn't work, but here are the full contents of my enable_error_logging.php file:

    Code:
    <?php
    /**
     * Very simple error logging to file
     *
     * Sometimes it is difficult to debug PHP background activities, especially when most information cannot be safely output to the screen.
     * However, using the PHP error logging facility we can store all PHP errors to a file, and then review separately.
     * Using this method, the debug details are stored at: /logs/myDEBUG-999999-00000000.log
     * Credits to @lat9 for adding backtrace functionality
     *
     * @package debug
     * @copyright Copyright 2003-2016 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: Author: DrByte  Sat Oct 17 20:09:58 2015 -0400 Modified in v1.5.5 $
     */
    
    function zen_debug_error_handler ($errno, $errstr, $errfile, $errline) {
      if (!(error_reporting() & $errno)) {
        return;
      }
      ob_start();
      if (version_compare(PHP_VERSION, '5.3.6') >= 0) {
        debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
      } else {
        debug_print_backtrace();
      }
      $backtrace = ob_get_contents();
      ob_end_clean();
      // The following line removes the call to this zen_debug_error_handler function (as it's not relevant)
      $backtrace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $backtrace, 1);  
      error_log('Request URI: ' . $_SERVER['REQUEST_URI'] . ', IP address: ' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'not set') . "\n" . $backtrace);
      
      return false;  // Let PHP's built-in error handler do its thing.
    }
    
    if (!defined('DIR_FS_LOGS')) {
      $val = realpath(dirname(DIR_FS_SQL_CACHE . '/') . '/logs');
      if (is_dir($val) && is_writable($val)) {
        define('DIR_FS_LOGS', $val);
      }
      else {
        define('DIR_FS_LOGS', DIR_FS_SQL_CACHE);
      }
    }
    /**
     * Specify the pages you wish to enable debugging for (ie: main_page=xxxxxxxx)
     * Using '*' will cause all pages to be enabled
     */
      $pages_to_debug[] = '*';
    //   $pages_to_debug[] = '';
    //   $pages_to_debug[] = '';
    
    /**
     * The path where the debug log file will be located
     * Default value is: DIR_FS_LOGS . '/myDEBUG-999999-00000000.log'
     * ... which puts it in the /logs/ folder:   /logs/myDEBUG-999999-00000000.log  (where 999999 is a random number, and 00000000 is the server's timestamp)
     *    (or if you don't have a /logs/ folder, it will use the /cache/ folder instead)
     */
      $debug_logfile_path = DIR_FS_LOGS . '/myDEBUG-' . time() . '-' . mt_rand(1000,999999) . '.log';
    
    /**
     * Error reporting level to log
     * Default: E_ALL ^E_NOTICE
     */
      $errors_to_log = (version_compare(PHP_VERSION, 5.3, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE : version_compare(PHP_VERSION, 5.4, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT : E_ALL & ~E_NOTICE);
    
    
    ///// DO NOT EDIT BELOW THIS LINE /////
    
    //////////////////// DEBUG HANDLING //////////////////////////////////
      if (in_array('*', $pages_to_debug) || in_array($current_page_base, $pages_to_debug)) {
        @ini_set('log_errors', 1);          // store to file
        @ini_set('log_errors_max_len', 0);  // unlimited length of message output
        @ini_set('display_errors', 0);      // do not output errors to screen/browser/client
        @ini_set('error_log', $debug_logfile_path);  // the filename to log errors into
        @ini_set('error_reporting', $errors_to_log ); // log only errors according to defined rules
        set_error_handler('zen_debug_error_handler', $errors_to_log);
      }
    
      if (defined('IS_CLI') && IS_CLI == 'VERBOSE') {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
      }
    If look at the version information found at the version link at the top of the admin screen, is ini_set disabled? Is the backtrace function disabled?
    On the top of my Admin screen, there is no mention of ini_set anywhere. It just tells me "You are presently using: v1.5.5f". I don't think any backtrace funtion would be disabled (I do see other errors in my log file that seems to backtrace the source........just not with these particular error files in question).
    - Jeff

  3. #13
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    58
    Plugin Contributions
    1

    Default Re: PHP Fatal error: Call to a member function get_template_dir() on null in credit_c

    Have you found a solution to this? I am getting the same error.

    Quote Originally Posted by Jeff_Mash View Post
    That link didn't work, but here are the full contents of my enable_error_logging.php file:

    Code:
    <?php
    /**
     * Very simple error logging to file
     *
     * Sometimes it is difficult to debug PHP background activities, especially when most information cannot be safely output to the screen.
     * However, using the PHP error logging facility we can store all PHP errors to a file, and then review separately.
     * Using this method, the debug details are stored at: /logs/myDEBUG-999999-00000000.log
     * Credits to @lat9 for adding backtrace functionality
     *
     * @package debug
     * @copyright Copyright 2003-2016 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: Author: DrByte  Sat Oct 17 20:09:58 2015 -0400 Modified in v1.5.5 $
     */
    
    function zen_debug_error_handler ($errno, $errstr, $errfile, $errline) {
      if (!(error_reporting() & $errno)) {
        return;
      }
      ob_start();
      if (version_compare(PHP_VERSION, '5.3.6') >= 0) {
        debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
      } else {
        debug_print_backtrace();
      }
      $backtrace = ob_get_contents();
      ob_end_clean();
      // The following line removes the call to this zen_debug_error_handler function (as it's not relevant)
      $backtrace = preg_replace ('/^#0\s+' . __FUNCTION__ . "[^\n]*\n/", '', $backtrace, 1);  
      error_log('Request URI: ' . $_SERVER['REQUEST_URI'] . ', IP address: ' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'not set') . "\n" . $backtrace);
      
      return false;  // Let PHP's built-in error handler do its thing.
    }
    
    if (!defined('DIR_FS_LOGS')) {
      $val = realpath(dirname(DIR_FS_SQL_CACHE . '/') . '/logs');
      if (is_dir($val) && is_writable($val)) {
        define('DIR_FS_LOGS', $val);
      }
      else {
        define('DIR_FS_LOGS', DIR_FS_SQL_CACHE);
      }
    }
    /**
     * Specify the pages you wish to enable debugging for (ie: main_page=xxxxxxxx)
     * Using '*' will cause all pages to be enabled
     */
      $pages_to_debug[] = '*';
    //   $pages_to_debug[] = '';
    //   $pages_to_debug[] = '';
    
    /**
     * The path where the debug log file will be located
     * Default value is: DIR_FS_LOGS . '/myDEBUG-999999-00000000.log'
     * ... which puts it in the /logs/ folder:   /logs/myDEBUG-999999-00000000.log  (where 999999 is a random number, and 00000000 is the server's timestamp)
     *    (or if you don't have a /logs/ folder, it will use the /cache/ folder instead)
     */
      $debug_logfile_path = DIR_FS_LOGS . '/myDEBUG-' . time() . '-' . mt_rand(1000,999999) . '.log';
    
    /**
     * Error reporting level to log
     * Default: E_ALL ^E_NOTICE
     */
      $errors_to_log = (version_compare(PHP_VERSION, 5.3, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE : version_compare(PHP_VERSION, 5.4, '>=') ? E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT : E_ALL & ~E_NOTICE);
    
    
    ///// DO NOT EDIT BELOW THIS LINE /////
    
    //////////////////// DEBUG HANDLING //////////////////////////////////
      if (in_array('*', $pages_to_debug) || in_array($current_page_base, $pages_to_debug)) {
        @ini_set('log_errors', 1);          // store to file
        @ini_set('log_errors_max_len', 0);  // unlimited length of message output
        @ini_set('display_errors', 0);      // do not output errors to screen/browser/client
        @ini_set('error_log', $debug_logfile_path);  // the filename to log errors into
        @ini_set('error_reporting', $errors_to_log ); // log only errors according to defined rules
        set_error_handler('zen_debug_error_handler', $errors_to_log);
      }
    
      if (defined('IS_CLI') && IS_CLI == 'VERBOSE') {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
      }


    On the top of my Admin screen, there is no mention of ini_set anywhere. It just tells me "You are presently using: v1.5.5f". I don't think any backtrace funtion would be disabled (I do see other errors in my log file that seems to backtrace the source........just not with these particular error files in question).

  4. #14
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    58
    Plugin Contributions
    1

    Default Re: PHP Fatal error: Call to a member function get_template_dir() on null in credit_c

    In my case, the reason seems to be some missing language files beginning with lang.xxx (which are now in v 1.5.8.)

    Quote Originally Posted by zamzom View Post
    Have you found a solution to this? I am getting the same error.

  5. #15
    Join Date
    May 2023
    Location
    Canada
    Posts
    50
    Plugin Contributions
    0

    Default Re: PHP Fatal error: Call to a member function get_template_dir() on null in credit_c

    Just for documentation, I have noticed that I can get the same error when I upload a plugin but make a mistake such as not renaming one of the files which expects to be renamed before upload, or mistyping one of the values like YOUR_ADMIN or YOUR_TEMPLATE. In those cases the customer-side of the store usually looks blank, and I just restore the site and database from backup rather than try and debug further.

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v155 PHP Fatal error: Call to a member function isMobile() on null
    By asdco in forum Basic Configuration
    Replies: 5
    Last Post: 12 Oct 2018, 11:03 AM
  2. Replies: 6
    Last Post: 21 Jun 2012, 12:16 AM
  3. Replies: 2
    Last Post: 16 Nov 2011, 05:29 AM
  4. Fatal error: Call to a member function get_template_dir() -- wordpress mod
    By rakhi in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 3 Jul 2007, 09:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR