asterisk2billing.org
http://forum.asterisk2billing.org/

Automated Cron Job Bugs
http://forum.asterisk2billing.org/viewtopic.php?f=16&t=4610
Page 1 of 1

Author:  infiniti_guy [ Mon Dec 01, 2008 9:06 pm ]
Post subject:  Automated Cron Job Bugs

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(";
}

:D

a2billing: branch/1.3 (1.3.4+)
db: postgres 8.3

Author:  stavros [ Mon Dec 01, 2008 9:57 pm ]
Post subject: 

Thanks. I can't believe I had never noticed this, as I'm one of the few here running A2B on Postgres.
Committed with other related fixes.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/