Enabling debug mode in config.php

The config.php has several variables to debug FrontAccounting from the simplest sql trail onwards to pdf debugging.

Enhanced sql_trail reporting

The standard sql_trail reports the sql error message if any. Using this commit in apmuthu GitHub repo, the following will appear prefixed to the message in the msg field.

  • For INSERT statements, the AUTO_INCREMENT field's last inserted id value prefixed with an I
  • For UPDATE / REPLACE statements, the number of affected rows prefixed with M

Inspecting variables in reports

  • Most if not all reports contain a Comments parameter that can be populated with various variables to be inspected.
  • Example diagnostic screenshot.
  • This Forum Post provides means to populate variables into a log file:
$log_output = print_r($array_var, true);
file_put_contents('D:/XAMPP/htdocs/fa23/tmp/log_file.txt', $log_output, FILE_APPEND);

The full path may be required for the log file above in some installs whilst in some the file may need to exist with the appropriate ownerships and permissions.

Inspecting Variables in FA code

  • If a custom module is installed in FA, then the installed_extensions.php files (both in the webroot and in the company folders should have the name element manually amended if it is different from the module's folder name.
  • To examine the state of a few variables just before activating / deactivating a custom extension for a company, we navigate to the file admin/inst_module.php and look at the line 216 that does the job:
			$activated = activate_hooks($ext['package'], $comp, !$ext['active']);	// change active state

We now place the following lines just before it:

$log_output = "\n\n Start dump of all variables \n\n" . print_r(get_defined_vars(),true) . "\n\n";
file_put_contents('D:/XAMPP/htdocs/fa23/tmp/log_file.txt', $log_output, FILE_APPEND);
  • Now activate and deactivate the installed extension and view the output of the file tmp/log_file.txt.
  • It will list all variables in global and local scope.
  • Choose the ones of interest and then fine tune the result subset by replacing the debug lines above with:
$log_output = "\n\n Start \n\n \$exts = " . print_r($exts,true) . "\n\n \$_POST = " . print_r($_POST,true) . "\n\n";
file_put_contents('D:/XAMPP/htdocs/fa23/tmp/log_file.txt', $log_output, FILE_APPEND);
  • Blank out the file tmp/log_file.txt
  • Now, again perform an activation and deactivation of the installed custom module and view it's contents:
  • Activation part of the log:
 Start 

 $exts = Array
(
    [1] => Array
        (
            [package] => simplehrm
            [name] => Simple HRM
            [version] => 2.3.24-1
            [available] => 
            [type] => extension
            [path] => modules/simplehrm
            [active] => 0
        )

)

 $_POST = Array
(
    [_random] => 490519.50853340235
    [_token] => f216fcf4593d1be472435e37c86fc1ecd10d8f85be093e604f479f1b62a69db9
    [_modified] => 0
    [_focus] => extset
    [Refresh] => Update
    [Active1] => 1
    [extset] => 2
)

  • Deactivation part of the log:

 $exts = Array
(
    [1] => Array
        (
            [package] => simplehrm
            [name] => Simple HRM
            [version] => 2.3.24-1
            [available] => 
            [type] => extension
            [path] => modules/simplehrm
            [active] => 1
        )

)

 $_POST = Array
(
    [_random] => 25475.323523664465
    [_token] => 55fc59ac2dcaef2cb80834c065787aaf52c1fab3625c4fb39ca7bc14e0bebb39
    [_modified] => 0
    [_focus] => extset
    [Refresh] => Update
    [extset] => 2
)

Use the enhanced var_dump debugger - kint | Usage

Troubleshoot cURL issues in FA

Troubleshoot Ajax in FA

  • Download Browser Console Library
  • Place the contents in the FA includes/ folder
  • In FA's includes/session.inc, append the following:
include_once($path_to_root . "/includes/ChromePhp.php");
function ConsoleDebug($obj){
    ChromePhp::log($obj);
}
  • To inspect any variable in FA, insert the following code at the desired location:
ConsoleDebug($anything);

Use __halt_compiler() function

  • Notes on usage are in the comments.