mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
Attempt to fix processwire/processwire-issues#122
This commit is contained in:
@@ -156,6 +156,31 @@ class PagesLoaderCache extends Wire {
|
||||
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.
|
||||
*
|
||||
@@ -170,12 +195,7 @@ class PagesLoaderCache extends Wire {
|
||||
public function getSelectorCache($selector, $options, $returnSelector = false) {
|
||||
|
||||
if(count($options)) {
|
||||
$optionsHash = '';
|
||||
ksort($options);
|
||||
foreach($options as $key => $value) {
|
||||
if(is_array($value)) $value = print_r($value, true);
|
||||
$optionsHash .= "[$key:$value]";
|
||||
}
|
||||
$optionsHash = $this->optionsArrayToString($options);
|
||||
$selector .= "," . $optionsHash;
|
||||
} else {
|
||||
$selector .= ",";
|
||||
|
Reference in New Issue
Block a user