provide 'per-page' caching for is_matrix_url() results to reduce duplicate queries
This commit is contained in:
parent
7763643f2e
commit
103cd2b7a1
@ -1,14 +1,24 @@
|
|||||||
<?php /** @file */
|
<?php /** @file */
|
||||||
|
|
||||||
function is_matrix_url($url) {
|
function is_matrix_url($url) {
|
||||||
|
|
||||||
|
static $remembered = [];
|
||||||
|
|
||||||
$m = @parse_url($url);
|
$m = @parse_url($url);
|
||||||
if($m['host']) {
|
if($m['host']) {
|
||||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
|
||||||
|
if(array_key_exists($m['host'],$remembered))
|
||||||
|
return $remembered[$m['host']];
|
||||||
|
|
||||||
|
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network = 'zot' limit 1",
|
||||||
dbesc($m['host'])
|
dbesc($m['host'])
|
||||||
);
|
);
|
||||||
if($r)
|
if($r) {
|
||||||
|
$remembered[$m['host']] = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
$remembered[$m['host']] = false;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user