aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-10-02 19:00:29 -0700
committerBrett Profitt <brett.profitt@gmail.com>2011-10-02 19:00:29 -0700
commit19277946b643c7024c1aaad813f287bead695f21 (patch)
tree52796bd6ac2ea9ceae01e06e775d711aee5beeee /engine/lib
parent21e808b132b47baf9d525650349ae276d4d751ec (diff)
downloadelgg-19277946b643c7024c1aaad813f287bead695f21.tar.gz
elgg-19277946b643c7024c1aaad813f287bead695f21.tar.bz2
Merged fixes for delayed queries from 1.7.
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/database.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 7747eb0d5..f12b50079 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -163,10 +163,17 @@ function db_delayedexecution_shutdown_hook() {
global $DB_DELAYED_QUERIES;
foreach ($DB_DELAYED_QUERIES as $query_details) {
- // use one of our db functions so it is included in profiling.
- $result = execute_query($query_details['q'], $query_details['l']);
-
try {
+ $link = $query_details['l'];
+
+ if ($link == 'read' || $link == 'write') {
+ $link = get_db_link($link);
+ } elseif (!is_resource($link)) {
+ elgg_log("Link for delayed query not valid resource or db_link type. Query: {$query_details['q']}", 'WARNING');
+ }
+
+ $result = execute_query($query_details['q'], $link);
+
if ((isset($query_details['h'])) && (is_callable($query_details['h']))) {
$query_details['h']($result);
}
@@ -272,7 +279,7 @@ function execute_query($query, $dblink) {
* the raw result from {@link mysql_query()}.
*
* @param string $query The query to execute
- * @param resource $dblink The database link to use
+ * @param resource $dblink The database link to use or the link type (read | write)
* @param string $handler A callback function to pass the results array to
*
* @return true
@@ -284,6 +291,10 @@ function execute_delayed_query($query, $dblink, $handler = "") {
$DB_DELAYED_QUERIES = array();
}
+ if (!is_resource($dblink) && $dblink != 'read' && $dblink != 'write') {
+ return false;
+ }
+
// Construct delayed query
$delayed_query = array();
$delayed_query['q'] = $query;
@@ -306,7 +317,7 @@ function execute_delayed_query($query, $dblink, $handler = "") {
* @uses get_db_link()
*/
function execute_delayed_write_query($query, $handler = "") {
- return execute_delayed_query($query, get_db_link('write'), $handler);
+ return execute_delayed_query($query, 'write', $handler);
}
/**
@@ -320,7 +331,7 @@ function execute_delayed_write_query($query, $handler = "") {
* @uses get_db_link()
*/
function execute_delayed_read_query($query, $handler = "") {
- return execute_delayed_query($query, get_db_link('read'), $handler);
+ return execute_delayed_query($query, 'read', $handler);
}
/**