Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
667e6ebc
Commit
667e6ebc
authored
Oct 11, 2017
by
Neill Magill
Browse files
MDL-60436 blocks: Improve performance of block loading
parent
4275ea4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/blocklib.php
View file @
667e6ebc
...
...
@@ -707,7 +707,7 @@ class block_manager {
if
(
$includeinvisible
)
{
$visiblecheck
=
''
;
}
else
{
$visiblecheck
=
'AND (bp.visible = 1 OR bp.visible IS NULL)'
;
$visiblecheck
=
'AND (bp.visible = 1 OR bp.visible IS
NULL) AND (bs.visible = 1 OR bs.visible IS
NULL)'
;
}
$context
=
$this
->
page
->
context
;
...
...
@@ -728,24 +728,26 @@ class block_manager {
$ccjoin
=
"LEFT JOIN
{
context
}
ctx ON (ctx.instanceid = bi.id AND ctx.contextlevel = :contextlevel)"
;
$systemcontext
=
context_system
::
instance
();
list
(
$bpcontext
,
$bpcontextidparams
)
=
$DB
->
get_in_or_equal
(
array
(
$context
->
id
,
$systemcontext
->
id
),
SQL_PARAMS_NAMED
,
'bpcontextid'
);
$params
=
array
(
'contextlevel'
=>
CONTEXT_BLOCK
,
'subpage1'
=>
$this
->
page
->
subpage
,
'subpage2'
=>
$this
->
page
->
subpage
,
'subpage3'
=>
$this
->
page
->
subpage
,
'contextid1'
=>
$context
->
id
,
'contextid2'
=>
$context
->
id
,
'contextid3'
=>
$systemcontext
->
id
,
'contextid4'
=>
$systemcontext
->
id
,
'pagetype'
=>
$this
->
page
->
pagetype
,
'pagetype2'
=>
$this
->
page
->
pagetype
,
);
if
(
$this
->
page
->
subpage
===
''
)
{
$params
[
'subpage1'
]
=
''
;
$params
[
'subpage2'
]
=
''
;
$params
[
'subpage3'
]
=
''
;
}
$sql
=
"SELECT
bi.id,
bp.id
AS blockpositionid,
COALESCE(bp.id, bs.id)
AS blockpositionid,
bi.blockname,
bi.parentcontextid,
bi.showinsubcontexts,
...
...
@@ -754,18 +756,22 @@ class block_manager {
bi.subpagepattern,
bi.defaultregion,
bi.defaultweight,
COALESCE(bp.visible, 1) AS visible,
COALESCE(bp.region, bi.defaultregion) AS region,
COALESCE(bp.weight, bi.defaultweight) AS weight,
COALESCE(bp.visible,
bs.visible,
1) AS visible,
COALESCE(bp.region,
bs.region,
bi.defaultregion) AS region,
COALESCE(bp.weight,
bs.weight,
bi.defaultweight) AS weight,
bi.configdata
$ccselect
FROM
{
block_instances
}
bi
JOIN
{
block
}
b ON bi.blockname = b.name
LEFT JOIN
{
block_positions
}
bp ON bp.blockinstanceid = bi.id
AND bp.contextid
$bp
context
AND bp.contextid
= :
context
id1
AND bp.pagetype = :pagetype
AND bp.subpage = :subpage1
LEFT JOIN
{
block_positions
}
bs ON bs.blockinstanceid = bi.id
AND bs.contextid = :contextid4
AND bs.pagetype = :pagetype2
AND bs.subpage = :subpage3
$ccjoin
WHERE
...
...
@@ -777,12 +783,11 @@ class block_manager {
$requiredbythemecheck
ORDER BY
COALESCE(bp.region, bi.defaultregion),
COALESCE(bp.weight, bi.defaultweight),
COALESCE(bp.region,
bs.region,
bi.defaultregion),
COALESCE(bp.weight,
bs.weight,
bi.defaultweight),
bi.id"
;
$allparams
=
$params
+
$parentcontextparams
+
$pagetypepatternparams
+
$requiredbythemeparams
;
$allparams
=
$allparams
+
$requiredbythemenotparams
+
$bpcontextidparams
;
$allparams
=
$params
+
$parentcontextparams
+
$pagetypepatternparams
+
$requiredbythemeparams
+
$requiredbythemenotparams
;
$blockinstances
=
$DB
->
get_recordset_sql
(
$sql
,
$allparams
);
$this
->
birecordsbyregion
=
$this
->
prepare_per_region_arrays
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment