Commit 6ea4bc6c authored by Dries's avatar Dries

- Patch #30801 by Allie Micka and m3avrck: performance improvements: improved...

- Patch #30801 by Allie Micka and m3avrck: performance improvements: improved the database scheme and queries of the block.module.
parent d995621f
......@@ -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;
--
......
......@@ -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)
);
--
......
......@@ -45,7 +45,8 @@
"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);
......
......@@ -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];
}
......
......@@ -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];
}
......
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