mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 16:26:59 +02:00
Attempt to fix processwire/processwire-issues#122
This commit is contained in:
@@ -156,6 +156,31 @@ class PagesLoaderCache extends Wire {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an options array to a string
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function optionsArrayToString(array $options) {
|
||||||
|
$str = '';
|
||||||
|
ksort($options);
|
||||||
|
foreach($options as $key => $value) {
|
||||||
|
if(is_array($value)) {
|
||||||
|
$value = $this->optionsArrayToString($value);
|
||||||
|
} else if(is_object($value)) {
|
||||||
|
if(method_exists($value, '__toString')) {
|
||||||
|
$value = (string) $value;
|
||||||
|
} else {
|
||||||
|
$value = wireClassName($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$str .= "[$key:$value]";
|
||||||
|
}
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve any cached page IDs for the given selector and options OR false if none found.
|
* Retrieve any cached page IDs for the given selector and options OR false if none found.
|
||||||
*
|
*
|
||||||
@@ -170,12 +195,7 @@ class PagesLoaderCache extends Wire {
|
|||||||
public function getSelectorCache($selector, $options, $returnSelector = false) {
|
public function getSelectorCache($selector, $options, $returnSelector = false) {
|
||||||
|
|
||||||
if(count($options)) {
|
if(count($options)) {
|
||||||
$optionsHash = '';
|
$optionsHash = $this->optionsArrayToString($options);
|
||||||
ksort($options);
|
|
||||||
foreach($options as $key => $value) {
|
|
||||||
if(is_array($value)) $value = print_r($value, true);
|
|
||||||
$optionsHash .= "[$key:$value]";
|
|
||||||
}
|
|
||||||
$selector .= "," . $optionsHash;
|
$selector .= "," . $optionsHash;
|
||||||
} else {
|
} else {
|
||||||
$selector .= ",";
|
$selector .= ",";
|
||||||
|
Reference in New Issue
Block a user