mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Using the method cache for the rest of the return statements in DboSource::name
This commit is contained in:
parent
753721c777
commit
6ae54fda8d
1 changed files with 6 additions and 6 deletions
|
@ -484,26 +484,26 @@ class DboSource extends DataSource {
|
|||
}
|
||||
return $data;
|
||||
}
|
||||
$cacheKey = crc32($data);
|
||||
$cacheKey = crc32($this->startQuote.$data.$this->endQuote);
|
||||
if (isset($this->methodCache[__FUNCTION__][$cacheKey])) {
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey];
|
||||
}
|
||||
$data = trim($data);
|
||||
if (preg_match('/^[\w-]+(\.[\w-]+)*$/', $data)) { // string, string.string
|
||||
if (strpos($data, '.') === false) { // string
|
||||
return $this->startQuote . $data . $this->endQuote;
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey] = $this->startQuote . $data . $this->endQuote;
|
||||
}
|
||||
$items = explode('.', $data);
|
||||
return $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote;
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey] = $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote;
|
||||
}
|
||||
if (preg_match('/^[\w-]+\.\*$/', $data)) { // string.*
|
||||
return $this->startQuote . str_replace('.*', $this->endQuote . '.*', $data);
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey] = $this->startQuote . str_replace('.*', $this->endQuote . '.*', $data);
|
||||
}
|
||||
if (preg_match('/^([\w-]+)\((.*)\)$/', $data, $matches)) { // Functions
|
||||
return $matches[1] . '(' . $this->name($matches[2]) . ')';
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey] = $matches[1] . '(' . $this->name($matches[2]) . ')';
|
||||
}
|
||||
if (preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/', $data, $matches)) {
|
||||
return preg_replace('/\s{2,}/', ' ', $this->name($matches[1]) . ' ' . $this->alias . ' ' . $this->name($matches[3]));
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey] = preg_replace('/\s{2,}/', ' ', $this->name($matches[1]) . ' ' . $this->alias . ' ' . $this->name($matches[3]));
|
||||
}
|
||||
return $this->methodCache[__FUNCTION__][$cacheKey] = $data;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue