aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-11-13 16:12:36 -0800
committerzotlabs <mike@macgirvin.com>2016-11-13 16:12:36 -0800
commit103cd2b7a15caaadd5ddf8a6b69c8e3de7a2982b (patch)
tree761f346248ae0165ebde9bcc4ac6ac52cfb5a1fc
parent7763643f2e55c82af97d5db5315f051ed9cc6090 (diff)
downloadvolse-hubzilla-103cd2b7a15caaadd5ddf8a6b69c8e3de7a2982b.tar.gz
volse-hubzilla-103cd2b7a15caaadd5ddf8a6b69c8e3de7a2982b.tar.bz2
volse-hubzilla-103cd2b7a15caaadd5ddf8a6b69c8e3de7a2982b.zip
provide 'per-page' caching for is_matrix_url() results to reduce duplicate queries
-rw-r--r--include/hubloc.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/include/hubloc.php b/include/hubloc.php
index 397646449..b660c1019 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -1,13 +1,23 @@
<?php /** @file */
function is_matrix_url($url) {
+
+ static $remembered = [];
+
$m = @parse_url($url);
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'])
);
- if($r)
+ if($r) {
+ $remembered[$m['host']] = true;
return true;
+ }
+ $remembered[$m['host']] = false;
}
return false;
}