summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-09-12 18:26:59 +0000
committerDries Buytaert <dries@buytaert.net>2005-09-12 18:26:59 +0000
commit6ea4bc6caa1fe80081324f5d49e9990e57b5ce7d (patch)
tree59377a177d7437c36e82e099724e9d029bff8b94
parentd995621f2e885e710523e4cc689155d5d12e874d (diff)
downloadbrdo-6ea4bc6caa1fe80081324f5d49e9990e57b5ce7d.tar.gz
brdo-6ea4bc6caa1fe80081324f5d49e9990e57b5ce7d.tar.bz2
- Patch #30801 by Allie Micka and m3avrck: performance improvements: improved the database scheme and queries of the block.module.
-rw-r--r--database/database.mysql3
-rw-r--r--database/database.pgsql3
-rw-r--r--database/updates.inc11
-rw-r--r--modules/block.module12
-rw-r--r--modules/block/block.module12
5 files changed, 32 insertions, 9 deletions
diff --git a/database/database.mysql b/database/database.mysql
index 920782aaa..ea9087668 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -128,7 +128,8 @@ CREATE TABLE blocks (
custom tinyint(2) DEFAULT '0' NOT NULL,
throttle tinyint(1) DEFAULT '0' NOT NULL,
visibility tinyint(1) DEFAULT '0' NOT NULL,
- pages text NOT NULL
+ pages text NOT NULL,
+ PRIMARY KEY (module, delta)
) TYPE=MyISAM;
--
diff --git a/database/database.pgsql b/database/database.pgsql
index f083a3bd9..885a82f4e 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -123,7 +123,8 @@ CREATE TABLE blocks (
custom smallint NOT NULL default '0',
throttle smallint NOT NULL default '0',
visibility smallint NOT NULL default '0',
- pages text NOT NULL default ''
+ pages text NOT NULL default '',
+ PRIMARY KEY (module, detla)
);
--
diff --git a/database/updates.inc b/database/updates.inc
index f6027f786..bb73e7235 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -45,7 +45,8 @@ $sql_updates = array(
"2005-08-08" => "update_144",
"2005-08-15" => "update_145",
"2005-08-25" => "update_146",
- "2005-09-07" => "update_147"
+ "2005-09-07" => "update_147",
+ "2005-09-12" => "update_148"
);
function update_110() {
@@ -790,6 +791,14 @@ function update_147() {
return $ret;
}
+function update_148() {
+ $ret = array();
+
+ $ret[] = update_sql('ALTER TABLE {blocks} ADD PRIMARY KEY (module, delta)');
+
+ return $ret;
+}
+
function update_sql($sql) {
$edit = $_POST["edit"];
$result = db_query($sql);
diff --git a/modules/block.module b/modules/block.module
index f507a53d5..9dfaec3ac 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -471,10 +471,12 @@ function block_list($region) {
static $blocks = array();
- if (!isset($blocks[$region])) {
- $blocks[$region] = array();
- $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 AND region = '%s' ORDER BY weight, module", $theme_key, $region);
+ if (!count($blocks)) {
+ $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key);
while ($block = db_fetch_array($result)) {
+ if(!isset($blocks[$block->region])) {
+ $blocks[$block->region] = array();
+ }
// Use the user's block visibility setting, if necessary
if ($block['custom'] != 0) {
if ($user->uid && isset($user->block[$block['module']][$block['delta']])) {
@@ -517,6 +519,10 @@ function block_list($region) {
}
}
}
+ // Create an empty array if there were no entries
+ if(!isset($blocks[$region])) {
+ $blocks[$region] = array();
+ }
return $blocks[$region];
}
diff --git a/modules/block/block.module b/modules/block/block.module
index f507a53d5..9dfaec3ac 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -471,10 +471,12 @@ function block_list($region) {
static $blocks = array();
- if (!isset($blocks[$region])) {
- $blocks[$region] = array();
- $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 AND region = '%s' ORDER BY weight, module", $theme_key, $region);
+ if (!count($blocks)) {
+ $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key);
while ($block = db_fetch_array($result)) {
+ if(!isset($blocks[$block->region])) {
+ $blocks[$block->region] = array();
+ }
// Use the user's block visibility setting, if necessary
if ($block['custom'] != 0) {
if ($user->uid && isset($user->block[$block['module']][$block['delta']])) {
@@ -517,6 +519,10 @@ function block_list($region) {
}
}
}
+ // Create an empty array if there were no entries
+ if(!isset($blocks[$region])) {
+ $blocks[$region] = array();
+ }
return $blocks[$region];
}