Commit f2dbb2e9 by Scott

Migrate db connection code to new system

parent 2a6d8fab
......@@ -78,11 +78,11 @@ $routing = array(
$operation = qa_post_text('qa_operation');
if (isset($routing[$operation])) {
qa_db_connect('qa_ajax_db_fail_handler');
$qa_db->connect('qa_ajax_db_fail_handler');
qa_initialize_postdb_plugins();
qa_initialize_buffering();
require QA_INCLUDE_DIR . 'ajax/' . $routing[$operation];
qa_db_disconnect();
$qa_db->disconnect();
}
......@@ -69,12 +69,13 @@ qa_register_core_modules();
qa_initialize_predb_plugins();
require_once QA_INCLUDE_DIR . 'qa-db.php';
qa_db_allow_connect();
$qa_db = qa_service('database');
$qa_db->allowConnect();
// $qa_autoconnect defaults to true so that optional plugins will load for external code. Q2A core
// code sets $qa_autoconnect to false so that we can use custom fail handlers.
if (!isset($qa_autoconnect) || $qa_autoconnect !== false) {
qa_db_connect('qa_page_db_fail_handler');
$qa_db->connect('qa_page_db_fail_handler');
qa_initialize_postdb_plugins();
}
......
......@@ -43,7 +43,7 @@ qa_report_process_stage('init_blob');
require_once QA_INCLUDE_DIR . 'app/blobs.php';
qa_db_connect('qa_blob_db_fail_handler');
$qa_db->connect('qa_blob_db_fail_handler');
qa_initialize_postdb_plugins();
$blob = qa_read_blob(qa_get('qa_blobid'));
......@@ -92,4 +92,4 @@ if (isset($blob) && isset($blob['content'])) {
header('HTTP/1.0 404 Not Found');
}
qa_db_disconnect();
$qa_db->disconnect();
......@@ -102,7 +102,7 @@ function qa_feed_load_ifcategory($categoryslugs, $allkey, $catkey, &$title,
// Connect to database and get the type of feed and category requested (in some cases these are overridden later)
qa_db_connect('qa_feed_db_fail_handler');
$qa_db->connect('qa_feed_db_fail_handler');
qa_initialize_postdb_plugins();
$requestlower = strtolower(qa_request());
......@@ -422,7 +422,7 @@ $lines[] = '</rss>';
// Disconnect here, once all output is ready to go
qa_db_disconnect();
$qa_db->disconnect();
// Output the XML - and we're done!
......
......@@ -43,7 +43,7 @@ qa_report_process_stage('init_image');
require_once QA_INCLUDE_DIR . 'db/cache.php';
qa_db_connect('qa_image_db_fail_handler');
$qa_db->connect('qa_image_db_fail_handler');
qa_initialize_postdb_plugins();
$blobid = qa_get('qa_blobid');
......@@ -89,4 +89,4 @@ if (isset($content)) {
}
}
qa_db_disconnect();
$qa_db->disconnect();
......@@ -32,7 +32,7 @@ require_once QA_INCLUDE_DIR . 'app/page.php';
global $qa_usage;
qa_report_process_stage('init_page');
qa_db_connect('qa_page_db_fail_handler');
$qa_db->connect('qa_page_db_fail_handler');
qa_initialize_postdb_plugins();
qa_page_queue_pending();
......@@ -62,4 +62,4 @@ if (is_array($qa_content)) {
$qa_usage->output();
}
qa_db_disconnect();
$qa_db->disconnect();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment