rpc: delay getting DB connection until absolutely necessary

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
Dan McGee 2009-02-14 17:16:39 -06:00 committed by Loui Chang
parent 6afc46cb4a
commit 0caa949e41

View file

@ -33,8 +33,6 @@ class AurJSON {
public function handle($http_data) {
// set content type header to json
header('content-type: application/json');
// set up db connection.
$this->dbh = db_connect();
// handle error states
if ( !isset($http_data['type']) || !isset($http_data['arg']) ) {
@ -43,6 +41,9 @@ class AurJSON {
// do the routing
if ( in_array($http_data['type'], $this->exposed_methods) ) {
// set up db connection.
$this->dbh = db_connect();
// ugh. this works. I hate you php.
$json = call_user_func_array(array(&$this,$http_data['type']),
$http_data['arg']);