Here's a bug I confirmed and fixed regarding cron job files.
Problem: a2billing_batch_process.php cron jobs does not read dbtype from config file properly causing postgres db installs to fail during execution.
Description: There is a variable called UNIX_TIMESTAMP that differs from mysql to postgres (see lines 30-40 area). The call to check for "postgres" is made BEFORE loading the configuration settings from a2billing.conf. This is a problem because the determination of dbtype is made before the code/process has the information and thus, postgres dbtype is NEVER evaluated as such.
Affected Files:
- a2billing_batch_process.php (UNIX_TIMESTAMP is used currently, needs be be fixed)
- a2billing_bill_diduse.php (UNIX_TIMESTAMP not currently used in code, should be fixed)
- a2billing_subscription_fee.php (UNIX_TIMESTAMP not currently used in code, should be fixed)
Fix: There is a simple fix to move the "if" statement after loading the configuration (basically move it down few lines of code). Here's how it should be after fix:
$A2B = new A2Billing();
$A2B -> load_conf($agi, NULL, 0, $idconfig);
if ($A2B->config["database"]['dbtype'] == "postgres"){
$UNIX_TIMESTAMP = "date_part('epoch',";
}else{
$UNIX_TIMESTAMP = "UNIX_TIMESTAMP(";
}
a2billing: branch/1.3 (1.3.4+)
db: postgres 8.3