Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using the method cache for the rest of the return statements in DboSo…

…urce::name
  • Loading branch information...
commit 6ae54fda8d4a57bb249b6205482563e4b0d2d40d 1 parent 753721c
@lorenzo lorenzo authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 cake/libs/model/datasources/dbo_source.php
View
12 cake/libs/model/datasources/dbo_source.php
@@ -484,26 +484,26 @@ function name($data) {
}
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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.