@@ -14,82 +14,82 @@ |
||
14 | 14 | */ |
15 | 15 | class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore |
16 | 16 | { |
17 | - /** |
|
18 | - * memcache instance |
|
19 | - * @var Memcache |
|
20 | - */ |
|
21 | - protected $memcache = null; |
|
17 | + /** |
|
18 | + * memcache instance |
|
19 | + * @var Memcache |
|
20 | + */ |
|
21 | + protected $memcache = null; |
|
22 | 22 | |
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->memcache = new Memcache(); |
|
26 | - $this->memcache->addServer( '127.0.0.1', 11211 ); |
|
27 | - } |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->memcache = new Memcache(); |
|
26 | + $this->memcache->addServer( '127.0.0.1', 11211 ); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Read values for a set of keys from cache |
|
31 | - * |
|
32 | - * @param array $keys list of keys to fetch |
|
33 | - * @return array list of values with the given keys used as indexes |
|
34 | - * @return boolean true on success, false on failure |
|
35 | - */ |
|
36 | - protected function read(array $keys) |
|
37 | - { |
|
38 | - $_keys = $lookup = array(); |
|
39 | - foreach ($keys as $k) { |
|
40 | - $_k = sha1($k); |
|
41 | - $_keys[] = $_k; |
|
42 | - $lookup[$_k] = $k; |
|
43 | - } |
|
44 | - $_res = array(); |
|
45 | - $res = $this->memcache->get($_keys); |
|
46 | - foreach ($res as $k => $v) { |
|
47 | - $_res[$lookup[$k]] = $v; |
|
48 | - } |
|
29 | + /** |
|
30 | + * Read values for a set of keys from cache |
|
31 | + * |
|
32 | + * @param array $keys list of keys to fetch |
|
33 | + * @return array list of values with the given keys used as indexes |
|
34 | + * @return boolean true on success, false on failure |
|
35 | + */ |
|
36 | + protected function read(array $keys) |
|
37 | + { |
|
38 | + $_keys = $lookup = array(); |
|
39 | + foreach ($keys as $k) { |
|
40 | + $_k = sha1($k); |
|
41 | + $_keys[] = $_k; |
|
42 | + $lookup[$_k] = $k; |
|
43 | + } |
|
44 | + $_res = array(); |
|
45 | + $res = $this->memcache->get($_keys); |
|
46 | + foreach ($res as $k => $v) { |
|
47 | + $_res[$lookup[$k]] = $v; |
|
48 | + } |
|
49 | 49 | |
50 | - return $_res; |
|
51 | - } |
|
50 | + return $_res; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Save values for a set of keys to cache |
|
55 | - * |
|
56 | - * @param array $keys list of values to save |
|
57 | - * @param int $expire expiration time |
|
58 | - * @return boolean true on success, false on failure |
|
59 | - */ |
|
60 | - protected function write(array $keys, $expire=null) |
|
61 | - { |
|
62 | - foreach ($keys as $k => $v) { |
|
63 | - $k = sha1($k); |
|
64 | - $this->memcache->set($k, $v, 0, $expire); |
|
65 | - } |
|
53 | + /** |
|
54 | + * Save values for a set of keys to cache |
|
55 | + * |
|
56 | + * @param array $keys list of values to save |
|
57 | + * @param int $expire expiration time |
|
58 | + * @return boolean true on success, false on failure |
|
59 | + */ |
|
60 | + protected function write(array $keys, $expire=null) |
|
61 | + { |
|
62 | + foreach ($keys as $k => $v) { |
|
63 | + $k = sha1($k); |
|
64 | + $this->memcache->set($k, $v, 0, $expire); |
|
65 | + } |
|
66 | 66 | |
67 | - return true; |
|
68 | - } |
|
67 | + return true; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Remove values from cache |
|
72 | - * |
|
73 | - * @param array $keys list of keys to delete |
|
74 | - * @return boolean true on success, false on failure |
|
75 | - */ |
|
76 | - protected function delete(array $keys) |
|
77 | - { |
|
78 | - foreach ($keys as $k) { |
|
79 | - $k = sha1($k); |
|
80 | - $this->memcache->delete($k); |
|
81 | - } |
|
70 | + /** |
|
71 | + * Remove values from cache |
|
72 | + * |
|
73 | + * @param array $keys list of keys to delete |
|
74 | + * @return boolean true on success, false on failure |
|
75 | + */ |
|
76 | + protected function delete(array $keys) |
|
77 | + { |
|
78 | + foreach ($keys as $k) { |
|
79 | + $k = sha1($k); |
|
80 | + $this->memcache->delete($k); |
|
81 | + } |
|
82 | 82 | |
83 | - return true; |
|
84 | - } |
|
83 | + return true; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Remove *all* values from cache |
|
88 | - * |
|
89 | - * @return boolean true on success, false on failure |
|
90 | - */ |
|
91 | - protected function purge() |
|
92 | - { |
|
93 | - return $this->memcache->flush(); |
|
94 | - } |
|
86 | + /** |
|
87 | + * Remove *all* values from cache |
|
88 | + * |
|
89 | + * @return boolean true on success, false on failure |
|
90 | + */ |
|
91 | + protected function purge() |
|
92 | + { |
|
93 | + return $this->memcache->flush(); |
|
94 | + } |
|
95 | 95 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function __construct() |
24 | 24 | { |
25 | 25 | $this->memcache = new Memcache(); |
26 | - $this->memcache->addServer( '127.0.0.1', 11211 ); |
|
26 | + $this->memcache->addServer('127.0.0.1', 11211); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param int $expire expiration time |
58 | 58 | * @return boolean true on success, false on failure |
59 | 59 | */ |
60 | - protected function write(array $keys, $expire=null) |
|
60 | + protected function write(array $keys, $expire = null) |
|
61 | 61 | { |
62 | 62 | foreach ($keys as $k => $v) { |
63 | 63 | $k = sha1($k); |
@@ -26,133 +26,133 @@ |
||
26 | 26 | */ |
27 | 27 | class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom |
28 | 28 | { |
29 | - // PDO instance |
|
30 | - protected $db; |
|
31 | - protected $fetch; |
|
32 | - protected $fetchTimestamp; |
|
33 | - protected $save; |
|
29 | + // PDO instance |
|
30 | + protected $db; |
|
31 | + protected $fetch; |
|
32 | + protected $fetchTimestamp; |
|
33 | + protected $save; |
|
34 | 34 | |
35 | - public function __construct() |
|
36 | - { |
|
37 | - try { |
|
38 | - $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
|
39 | - } catch (PDOException $e) { |
|
40 | - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
41 | - } |
|
42 | - $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id'); |
|
43 | - $this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id'); |
|
44 | - $this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content) |
|
35 | + public function __construct() |
|
36 | + { |
|
37 | + try { |
|
38 | + $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
|
39 | + } catch (PDOException $e) { |
|
40 | + throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
41 | + } |
|
42 | + $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id'); |
|
43 | + $this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id'); |
|
44 | + $this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content) |
|
45 | 45 | VALUES (:id, :name, :cache_id, :compile_id, :content)'); |
46 | - } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * fetch cached content and its modification time from data source |
|
50 | - * |
|
51 | - * @param string $id unique cache content identifier |
|
52 | - * @param string $name template name |
|
53 | - * @param string $cache_id cache id |
|
54 | - * @param string $compile_id compile id |
|
55 | - * @param string $content cached content |
|
56 | - * @param integer $mtime cache modification timestamp (epoch) |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime) |
|
60 | - { |
|
61 | - $this->fetch->execute(array('id' => $id)); |
|
62 | - $row = $this->fetch->fetch(); |
|
63 | - $this->fetch->closeCursor(); |
|
64 | - if ($row) { |
|
65 | - $content = $row['content']; |
|
66 | - $mtime = strtotime($row['modified']); |
|
67 | - } else { |
|
68 | - $content = null; |
|
69 | - $mtime = null; |
|
70 | - } |
|
71 | - } |
|
48 | + /** |
|
49 | + * fetch cached content and its modification time from data source |
|
50 | + * |
|
51 | + * @param string $id unique cache content identifier |
|
52 | + * @param string $name template name |
|
53 | + * @param string $cache_id cache id |
|
54 | + * @param string $compile_id compile id |
|
55 | + * @param string $content cached content |
|
56 | + * @param integer $mtime cache modification timestamp (epoch) |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime) |
|
60 | + { |
|
61 | + $this->fetch->execute(array('id' => $id)); |
|
62 | + $row = $this->fetch->fetch(); |
|
63 | + $this->fetch->closeCursor(); |
|
64 | + if ($row) { |
|
65 | + $content = $row['content']; |
|
66 | + $mtime = strtotime($row['modified']); |
|
67 | + } else { |
|
68 | + $content = null; |
|
69 | + $mtime = null; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Fetch cached content's modification timestamp from data source |
|
75 | - * |
|
76 | - * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content. |
|
77 | - * @param string $id unique cache content identifier |
|
78 | - * @param string $name template name |
|
79 | - * @param string $cache_id cache id |
|
80 | - * @param string $compile_id compile id |
|
81 | - * @return integer|boolean timestamp (epoch) the template was modified, or false if not found |
|
82 | - */ |
|
83 | - protected function fetchTimestamp($id, $name, $cache_id, $compile_id) |
|
84 | - { |
|
85 | - $this->fetchTimestamp->execute(array('id' => $id)); |
|
86 | - $mtime = strtotime($this->fetchTimestamp->fetchColumn()); |
|
87 | - $this->fetchTimestamp->closeCursor(); |
|
73 | + /** |
|
74 | + * Fetch cached content's modification timestamp from data source |
|
75 | + * |
|
76 | + * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content. |
|
77 | + * @param string $id unique cache content identifier |
|
78 | + * @param string $name template name |
|
79 | + * @param string $cache_id cache id |
|
80 | + * @param string $compile_id compile id |
|
81 | + * @return integer|boolean timestamp (epoch) the template was modified, or false if not found |
|
82 | + */ |
|
83 | + protected function fetchTimestamp($id, $name, $cache_id, $compile_id) |
|
84 | + { |
|
85 | + $this->fetchTimestamp->execute(array('id' => $id)); |
|
86 | + $mtime = strtotime($this->fetchTimestamp->fetchColumn()); |
|
87 | + $this->fetchTimestamp->closeCursor(); |
|
88 | 88 | |
89 | - return $mtime; |
|
90 | - } |
|
89 | + return $mtime; |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Save content to cache |
|
94 | - * |
|
95 | - * @param string $id unique cache content identifier |
|
96 | - * @param string $name template name |
|
97 | - * @param string $cache_id cache id |
|
98 | - * @param string $compile_id compile id |
|
99 | - * @param integer|null $exp_time seconds till expiration time in seconds or null |
|
100 | - * @param string $content content to cache |
|
101 | - * @return boolean success |
|
102 | - */ |
|
103 | - protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content) |
|
104 | - { |
|
105 | - $this->save->execute(array( |
|
106 | - 'id' => $id, |
|
107 | - 'name' => $name, |
|
108 | - 'cache_id' => $cache_id, |
|
109 | - 'compile_id' => $compile_id, |
|
110 | - 'content' => $content, |
|
111 | - )); |
|
92 | + /** |
|
93 | + * Save content to cache |
|
94 | + * |
|
95 | + * @param string $id unique cache content identifier |
|
96 | + * @param string $name template name |
|
97 | + * @param string $cache_id cache id |
|
98 | + * @param string $compile_id compile id |
|
99 | + * @param integer|null $exp_time seconds till expiration time in seconds or null |
|
100 | + * @param string $content content to cache |
|
101 | + * @return boolean success |
|
102 | + */ |
|
103 | + protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content) |
|
104 | + { |
|
105 | + $this->save->execute(array( |
|
106 | + 'id' => $id, |
|
107 | + 'name' => $name, |
|
108 | + 'cache_id' => $cache_id, |
|
109 | + 'compile_id' => $compile_id, |
|
110 | + 'content' => $content, |
|
111 | + )); |
|
112 | 112 | |
113 | - return !!$this->save->rowCount(); |
|
114 | - } |
|
113 | + return !!$this->save->rowCount(); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Delete content from cache |
|
118 | - * |
|
119 | - * @param string $name template name |
|
120 | - * @param string $cache_id cache id |
|
121 | - * @param string $compile_id compile id |
|
122 | - * @param integer|null $exp_time seconds till expiration or null |
|
123 | - * @return integer number of deleted caches |
|
124 | - */ |
|
125 | - protected function delete($name, $cache_id, $compile_id, $exp_time) |
|
126 | - { |
|
127 | - // delete the whole cache |
|
128 | - if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { |
|
129 | - // returning the number of deleted caches would require a second query to count them |
|
130 | - $query = $this->db->query('TRUNCATE TABLE output_cache'); |
|
116 | + /** |
|
117 | + * Delete content from cache |
|
118 | + * |
|
119 | + * @param string $name template name |
|
120 | + * @param string $cache_id cache id |
|
121 | + * @param string $compile_id compile id |
|
122 | + * @param integer|null $exp_time seconds till expiration or null |
|
123 | + * @return integer number of deleted caches |
|
124 | + */ |
|
125 | + protected function delete($name, $cache_id, $compile_id, $exp_time) |
|
126 | + { |
|
127 | + // delete the whole cache |
|
128 | + if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { |
|
129 | + // returning the number of deleted caches would require a second query to count them |
|
130 | + $query = $this->db->query('TRUNCATE TABLE output_cache'); |
|
131 | 131 | |
132 | - return -1; |
|
133 | - } |
|
134 | - // build the filter |
|
135 | - $where = array(); |
|
136 | - // equal test name |
|
137 | - if ($name !== null) { |
|
138 | - $where[] = 'name = ' . $this->db->quote($name); |
|
139 | - } |
|
140 | - // equal test compile_id |
|
141 | - if ($compile_id !== null) { |
|
142 | - $where[] = 'compile_id = ' . $this->db->quote($compile_id); |
|
143 | - } |
|
144 | - // range test expiration time |
|
145 | - if ($exp_time !== null) { |
|
146 | - $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)'; |
|
147 | - } |
|
148 | - // equal test cache_id and match sub-groups |
|
149 | - if ($cache_id !== null) { |
|
150 | - $where[] = '(cache_id = '. $this->db->quote($cache_id) |
|
151 | - . ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')'; |
|
152 | - } |
|
153 | - // run delete query |
|
154 | - $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where)); |
|
132 | + return -1; |
|
133 | + } |
|
134 | + // build the filter |
|
135 | + $where = array(); |
|
136 | + // equal test name |
|
137 | + if ($name !== null) { |
|
138 | + $where[] = 'name = ' . $this->db->quote($name); |
|
139 | + } |
|
140 | + // equal test compile_id |
|
141 | + if ($compile_id !== null) { |
|
142 | + $where[] = 'compile_id = ' . $this->db->quote($compile_id); |
|
143 | + } |
|
144 | + // range test expiration time |
|
145 | + if ($exp_time !== null) { |
|
146 | + $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)'; |
|
147 | + } |
|
148 | + // equal test cache_id and match sub-groups |
|
149 | + if ($cache_id !== null) { |
|
150 | + $where[] = '(cache_id = '. $this->db->quote($cache_id) |
|
151 | + . ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')'; |
|
152 | + } |
|
153 | + // run delete query |
|
154 | + $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where)); |
|
155 | 155 | |
156 | - return $query->rowCount(); |
|
157 | - } |
|
156 | + return $query->rowCount(); |
|
157 | + } |
|
158 | 158 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | try { |
38 | 38 | $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
39 | 39 | } catch (PDOException $e) { |
40 | - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
40 | + throw new SmartyException('Mysql Resource failed: '.$e->getMessage()); |
|
41 | 41 | } |
42 | 42 | $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id'); |
43 | 43 | $this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id'); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'content' => $content, |
111 | 111 | )); |
112 | 112 | |
113 | - return !!$this->save->rowCount(); |
|
113 | + return ! ! $this->save->rowCount(); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -135,23 +135,23 @@ discard block |
||
135 | 135 | $where = array(); |
136 | 136 | // equal test name |
137 | 137 | if ($name !== null) { |
138 | - $where[] = 'name = ' . $this->db->quote($name); |
|
138 | + $where[] = 'name = '.$this->db->quote($name); |
|
139 | 139 | } |
140 | 140 | // equal test compile_id |
141 | 141 | if ($compile_id !== null) { |
142 | - $where[] = 'compile_id = ' . $this->db->quote($compile_id); |
|
142 | + $where[] = 'compile_id = '.$this->db->quote($compile_id); |
|
143 | 143 | } |
144 | 144 | // range test expiration time |
145 | 145 | if ($exp_time !== null) { |
146 | - $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)'; |
|
146 | + $where[] = 'modified < DATE_SUB(NOW(), INTERVAL '.intval($exp_time).' SECOND)'; |
|
147 | 147 | } |
148 | 148 | // equal test cache_id and match sub-groups |
149 | 149 | if ($cache_id !== null) { |
150 | - $where[] = '(cache_id = '. $this->db->quote($cache_id) |
|
151 | - . ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')'; |
|
150 | + $where[] = '(cache_id = '.$this->db->quote($cache_id) |
|
151 | + . ' OR cache_id LIKE '.$this->db->quote($cache_id.'|%').')'; |
|
152 | 152 | } |
153 | 153 | // run delete query |
154 | - $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where)); |
|
154 | + $query = $this->db->query('DELETE FROM output_cache WHERE '.join(' AND ', $where)); |
|
155 | 155 | |
156 | 156 | return $query->rowCount(); |
157 | 157 | } |
@@ -11,48 +11,48 @@ |
||
11 | 11 | */ |
12 | 12 | class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends |
13 | 13 | { |
14 | - /** |
|
15 | - * populate Source Object with meta data from Resource |
|
16 | - * |
|
17 | - * @param Smarty_Template_Source $source source object |
|
18 | - * @param Smarty_Internal_Template $_template template object |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) |
|
22 | - { |
|
23 | - $uid = ''; |
|
24 | - $sources = array(); |
|
25 | - $exists = true; |
|
26 | - foreach ($_template->smarty->getTemplateDir() as $key => $directory) { |
|
27 | - try { |
|
28 | - $s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name ); |
|
29 | - if (!$s->exists) { |
|
30 | - continue; |
|
31 | - } |
|
32 | - $sources[$s->uid] = $s; |
|
33 | - $uid .= $s->filepath; |
|
34 | - } catch (SmartyException $e) {} |
|
35 | - } |
|
14 | + /** |
|
15 | + * populate Source Object with meta data from Resource |
|
16 | + * |
|
17 | + * @param Smarty_Template_Source $source source object |
|
18 | + * @param Smarty_Internal_Template $_template template object |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) |
|
22 | + { |
|
23 | + $uid = ''; |
|
24 | + $sources = array(); |
|
25 | + $exists = true; |
|
26 | + foreach ($_template->smarty->getTemplateDir() as $key => $directory) { |
|
27 | + try { |
|
28 | + $s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name ); |
|
29 | + if (!$s->exists) { |
|
30 | + continue; |
|
31 | + } |
|
32 | + $sources[$s->uid] = $s; |
|
33 | + $uid .= $s->filepath; |
|
34 | + } catch (SmartyException $e) {} |
|
35 | + } |
|
36 | 36 | |
37 | - if (!$sources) { |
|
38 | - $source->exists = false; |
|
39 | - $source->template = $_template; |
|
37 | + if (!$sources) { |
|
38 | + $source->exists = false; |
|
39 | + $source->template = $_template; |
|
40 | 40 | |
41 | - return; |
|
42 | - } |
|
41 | + return; |
|
42 | + } |
|
43 | 43 | |
44 | - $sources = array_reverse($sources, true); |
|
45 | - reset($sources); |
|
46 | - $s = current($sources); |
|
44 | + $sources = array_reverse($sources, true); |
|
45 | + reset($sources); |
|
46 | + $s = current($sources); |
|
47 | 47 | |
48 | - $source->components = $sources; |
|
49 | - $source->filepath = $s->filepath; |
|
50 | - $source->uid = sha1($uid); |
|
51 | - $source->exists = $exists; |
|
52 | - if ($_template && $_template->smarty->compile_check) { |
|
53 | - $source->timestamp = $s->timestamp; |
|
54 | - } |
|
55 | - // need the template at getContent() |
|
56 | - $source->template = $_template; |
|
57 | - } |
|
48 | + $source->components = $sources; |
|
49 | + $source->filepath = $s->filepath; |
|
50 | + $source->uid = sha1($uid); |
|
51 | + $source->exists = $exists; |
|
52 | + if ($_template && $_template->smarty->compile_check) { |
|
53 | + $source->timestamp = $s->timestamp; |
|
54 | + } |
|
55 | + // need the template at getContent() |
|
56 | + $source->template = $_template; |
|
57 | + } |
|
58 | 58 | } |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | * @param Smarty_Internal_Template $_template template object |
19 | 19 | * @return void |
20 | 20 | */ |
21 | - public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) |
|
21 | + public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
22 | 22 | { |
23 | 23 | $uid = ''; |
24 | 24 | $sources = array(); |
25 | 25 | $exists = true; |
26 | 26 | foreach ($_template->smarty->getTemplateDir() as $key => $directory) { |
27 | 27 | try { |
28 | - $s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name ); |
|
29 | - if (!$s->exists) { |
|
28 | + $s = Smarty_Resource::source(null, $source->smarty, '['.$key.']'.$source->name); |
|
29 | + if ( ! $s->exists) { |
|
30 | 30 | continue; |
31 | 31 | } |
32 | 32 | $sources[$s->uid] = $s; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } catch (SmartyException $e) {} |
35 | 35 | } |
36 | 36 | |
37 | - if (!$sources) { |
|
37 | + if ( ! $sources) { |
|
38 | 38 | $source->exists = false; |
39 | 39 | $source->template = $_template; |
40 | 40 |
@@ -22,59 +22,59 @@ |
||
22 | 22 | */ |
23 | 23 | class Smarty_Resource_Mysql extends Smarty_Resource_Custom |
24 | 24 | { |
25 | - // PDO instance |
|
26 | - protected $db; |
|
27 | - // prepared fetch() statement |
|
28 | - protected $fetch; |
|
29 | - // prepared fetchTimestamp() statement |
|
30 | - protected $mtime; |
|
25 | + // PDO instance |
|
26 | + protected $db; |
|
27 | + // prepared fetch() statement |
|
28 | + protected $fetch; |
|
29 | + // prepared fetchTimestamp() statement |
|
30 | + protected $mtime; |
|
31 | 31 | |
32 | - public function __construct() |
|
33 | - { |
|
34 | - try { |
|
35 | - $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
|
36 | - } catch (PDOException $e) { |
|
37 | - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
38 | - } |
|
39 | - $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); |
|
40 | - $this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name'); |
|
41 | - } |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | + try { |
|
35 | + $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
|
36 | + } catch (PDOException $e) { |
|
37 | + throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
38 | + } |
|
39 | + $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); |
|
40 | + $this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Fetch a template and its modification time from database |
|
45 | - * |
|
46 | - * @param string $name template name |
|
47 | - * @param string $source template source |
|
48 | - * @param integer $mtime template modification timestamp (epoch) |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - protected function fetch($name, &$source, &$mtime) |
|
52 | - { |
|
53 | - $this->fetch->execute(array('name' => $name)); |
|
54 | - $row = $this->fetch->fetch(); |
|
55 | - $this->fetch->closeCursor(); |
|
56 | - if ($row) { |
|
57 | - $source = $row['source']; |
|
58 | - $mtime = strtotime($row['modified']); |
|
59 | - } else { |
|
60 | - $source = null; |
|
61 | - $mtime = null; |
|
62 | - } |
|
63 | - } |
|
43 | + /** |
|
44 | + * Fetch a template and its modification time from database |
|
45 | + * |
|
46 | + * @param string $name template name |
|
47 | + * @param string $source template source |
|
48 | + * @param integer $mtime template modification timestamp (epoch) |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + protected function fetch($name, &$source, &$mtime) |
|
52 | + { |
|
53 | + $this->fetch->execute(array('name' => $name)); |
|
54 | + $row = $this->fetch->fetch(); |
|
55 | + $this->fetch->closeCursor(); |
|
56 | + if ($row) { |
|
57 | + $source = $row['source']; |
|
58 | + $mtime = strtotime($row['modified']); |
|
59 | + } else { |
|
60 | + $source = null; |
|
61 | + $mtime = null; |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Fetch a template's modification time from database |
|
67 | - * |
|
68 | - * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source. |
|
69 | - * @param string $name template name |
|
70 | - * @return integer timestamp (epoch) the template was modified |
|
71 | - */ |
|
72 | - protected function fetchTimestamp($name) |
|
73 | - { |
|
74 | - $this->mtime->execute(array('name' => $name)); |
|
75 | - $mtime = $this->mtime->fetchColumn(); |
|
76 | - $this->mtime->closeCursor(); |
|
65 | + /** |
|
66 | + * Fetch a template's modification time from database |
|
67 | + * |
|
68 | + * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source. |
|
69 | + * @param string $name template name |
|
70 | + * @return integer timestamp (epoch) the template was modified |
|
71 | + */ |
|
72 | + protected function fetchTimestamp($name) |
|
73 | + { |
|
74 | + $this->mtime->execute(array('name' => $name)); |
|
75 | + $mtime = $this->mtime->fetchColumn(); |
|
76 | + $this->mtime->closeCursor(); |
|
77 | 77 | |
78 | - return strtotime($mtime); |
|
79 | - } |
|
78 | + return strtotime($mtime); |
|
79 | + } |
|
80 | 80 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | try { |
36 | 36 | $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
37 | 37 | } catch (PDOException $e) { |
38 | - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
38 | + throw new SmartyException('Mysql Resource failed: '.$e->getMessage()); |
|
39 | 39 | } |
40 | 40 | $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); |
41 | 41 | } |
@@ -25,40 +25,40 @@ |
||
25 | 25 | */ |
26 | 26 | class Smarty_Resource_Mysqls extends Smarty_Resource_Custom |
27 | 27 | { |
28 | - // PDO instance |
|
29 | - protected $db; |
|
30 | - // prepared fetch() statement |
|
31 | - protected $fetch; |
|
28 | + // PDO instance |
|
29 | + protected $db; |
|
30 | + // prepared fetch() statement |
|
31 | + protected $fetch; |
|
32 | 32 | |
33 | - public function __construct() |
|
34 | - { |
|
35 | - try { |
|
36 | - $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
|
37 | - } catch (PDOException $e) { |
|
38 | - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
39 | - } |
|
40 | - $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); |
|
41 | - } |
|
33 | + public function __construct() |
|
34 | + { |
|
35 | + try { |
|
36 | + $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
|
37 | + } catch (PDOException $e) { |
|
38 | + throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
39 | + } |
|
40 | + $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Fetch a template and its modification time from database |
|
45 | - * |
|
46 | - * @param string $name template name |
|
47 | - * @param string $source template source |
|
48 | - * @param integer $mtime template modification timestamp (epoch) |
|
49 | - * @return void |
|
50 | - */ |
|
51 | - protected function fetch($name, &$source, &$mtime) |
|
52 | - { |
|
53 | - $this->fetch->execute(array('name' => $name)); |
|
54 | - $row = $this->fetch->fetch(); |
|
55 | - $this->fetch->closeCursor(); |
|
56 | - if ($row) { |
|
57 | - $source = $row['source']; |
|
58 | - $mtime = strtotime($row['modified']); |
|
59 | - } else { |
|
60 | - $source = null; |
|
61 | - $mtime = null; |
|
62 | - } |
|
63 | - } |
|
43 | + /** |
|
44 | + * Fetch a template and its modification time from database |
|
45 | + * |
|
46 | + * @param string $name template name |
|
47 | + * @param string $source template source |
|
48 | + * @param integer $mtime template modification timestamp (epoch) |
|
49 | + * @return void |
|
50 | + */ |
|
51 | + protected function fetch($name, &$source, &$mtime) |
|
52 | + { |
|
53 | + $this->fetch->execute(array('name' => $name)); |
|
54 | + $row = $this->fetch->fetch(); |
|
55 | + $this->fetch->closeCursor(); |
|
56 | + if ($row) { |
|
57 | + $source = $row['source']; |
|
58 | + $mtime = strtotime($row['modified']); |
|
59 | + } else { |
|
60 | + $source = null; |
|
61 | + $mtime = null; |
|
62 | + } |
|
63 | + } |
|
64 | 64 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | try { |
36 | 36 | $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); |
37 | 37 | } catch (PDOException $e) { |
38 | - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); |
|
38 | + throw new SmartyException('Mysql Resource failed: '.$e->getMessage()); |
|
39 | 39 | } |
40 | 40 | $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); |
41 | 41 | } |
@@ -28,15 +28,15 @@ |
||
28 | 28 | define('DS', DIRECTORY_SEPARATOR); |
29 | 29 | define('ROOT', dirname(__FILE__)); |
30 | 30 | define('WEBROOT_DIR', 'webroot'); |
31 | -define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS); |
|
31 | +define('WWW_ROOT', ROOT.DS.APP_DIR.DS.WEBROOT_DIR.DS); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * This only needs to be changed if the "cake" directory is located |
35 | 35 | * outside of the distributed structure. |
36 | 36 | * Full path to the directory containing "cake". Do not add trailing directory separator |
37 | 37 | */ |
38 | -if (!defined('CAKE_CORE_INCLUDE_PATH')) { |
|
39 | - define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); |
|
38 | +if ( ! defined('CAKE_CORE_INCLUDE_PATH')) { |
|
39 | + define('CAKE_CORE_INCLUDE_PATH', ROOT.DS.'lib'); |
|
40 | 40 | } |
41 | 41 | |
42 | -require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php'; |
|
42 | +require APP_DIR.DS.WEBROOT_DIR.DS.'index.php'; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $current = self::$_config[$name]; |
130 | 130 | } |
131 | 131 | |
132 | - if (!empty($settings)) { |
|
132 | + if ( ! empty($settings)) { |
|
133 | 133 | self::$_config[$name] = array_merge($current, $settings); |
134 | 134 | } |
135 | 135 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | - if (!empty(self::$_config[$name]['groups'])) { |
|
140 | + if ( ! empty(self::$_config[$name]['groups'])) { |
|
141 | 141 | foreach (self::$_config[$name]['groups'] as $group) { |
142 | 142 | self::$_groups[$group][] = $name; |
143 | 143 | sort(self::$_groups[$group]); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | $engine = self::$_config[$name]['engine']; |
149 | 149 | |
150 | - if (!isset(self::$_engines[$name])) { |
|
150 | + if ( ! isset(self::$_engines[$name])) { |
|
151 | 151 | self::_buildEngine($name); |
152 | 152 | $settings = self::$_config[$name] = self::settings($name); |
153 | 153 | } elseif ($settings = self::set(self::$_config[$name], null, $name)) { |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | $config = self::$_config[$name]; |
168 | 168 | |
169 | 169 | list($plugin, $class) = pluginSplit($config['engine'], true); |
170 | - $cacheClass = $class . 'Engine'; |
|
171 | - App::uses($cacheClass, $plugin . 'Cache/Engine'); |
|
172 | - if (!class_exists($cacheClass)) { |
|
170 | + $cacheClass = $class.'Engine'; |
|
171 | + App::uses($cacheClass, $plugin.'Cache/Engine'); |
|
172 | + if ( ! class_exists($cacheClass)) { |
|
173 | 173 | throw new CacheException(__d('cake_dev', 'Cache engine %s is not available.', $name)); |
174 | 174 | } |
175 | - $cacheClass = $class . 'Engine'; |
|
176 | - if (!is_subclass_of($cacheClass, 'CacheEngine')) { |
|
175 | + $cacheClass = $class.'Engine'; |
|
176 | + if ( ! is_subclass_of($cacheClass, 'CacheEngine')) { |
|
177 | 177 | throw new CacheException(__d('cake_dev', 'Cache engines must use %s as a base class.', 'CacheEngine')); |
178 | 178 | } |
179 | 179 | self::$_engines[$name] = new $cacheClass(); |
180 | - if (!self::$_engines[$name]->init($config)) { |
|
180 | + if ( ! self::$_engines[$name]->init($config)) { |
|
181 | 181 | throw new CacheException(__d('cake_dev', 'Cache engine %s is not properly configured.', $name)); |
182 | 182 | } |
183 | 183 | if (self::$_engines[$name]->settings['probability'] && time() % self::$_engines[$name]->settings['probability'] === 0) { |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return boolean success of the removal, returns false when the config does not exist. |
205 | 205 | */ |
206 | 206 | public static function drop($name) { |
207 | - if (!isset(self::$_config[$name])) { |
|
207 | + if ( ! isset(self::$_config[$name])) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | unset(self::$_config[$name], self::$_engines[$name]); |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | if (is_array($settings) && $value !== null) { |
239 | 239 | $config = $value; |
240 | 240 | } |
241 | - if (!isset(self::$_config[$config]) || !isset(self::$_engines[$config])) { |
|
241 | + if ( ! isset(self::$_config[$config]) || ! isset(self::$_engines[$config])) { |
|
242 | 242 | return false; |
243 | 243 | } |
244 | - if (!empty($settings)) { |
|
244 | + if ( ! empty($settings)) { |
|
245 | 245 | self::$_reset = true; |
246 | 246 | } |
247 | 247 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $settings = array($settings => $value); |
255 | 255 | } |
256 | 256 | $settings = array_merge(self::$_config[$config], $settings); |
257 | - if (isset($settings['duration']) && !is_numeric($settings['duration'])) { |
|
257 | + if (isset($settings['duration']) && ! is_numeric($settings['duration'])) { |
|
258 | 258 | $settings['duration'] = strtotime($settings['duration']) - time(); |
259 | 259 | } |
260 | 260 | } |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | if (empty($settings)) { |
301 | 301 | return false; |
302 | 302 | } |
303 | - if (!self::isInitialized($config)) { |
|
303 | + if ( ! self::isInitialized($config)) { |
|
304 | 304 | return false; |
305 | 305 | } |
306 | 306 | $key = self::$_engines[$config]->key($key); |
307 | 307 | |
308 | - if (!$key || is_resource($value)) { |
|
308 | + if ( ! $key || is_resource($value)) { |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | |
312 | - $success = self::$_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']); |
|
312 | + $success = self::$_engines[$config]->write($settings['prefix'].$key, $value, $settings['duration']); |
|
313 | 313 | self::set(null, $config); |
314 | 314 | if ($success === false && $value !== '') { |
315 | 315 | trigger_error( |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | if (empty($settings)) { |
349 | 349 | return false; |
350 | 350 | } |
351 | - if (!self::isInitialized($config)) { |
|
351 | + if ( ! self::isInitialized($config)) { |
|
352 | 352 | return false; |
353 | 353 | } |
354 | 354 | $key = self::$_engines[$config]->key($key); |
355 | - if (!$key) { |
|
355 | + if ( ! $key) { |
|
356 | 356 | return false; |
357 | 357 | } |
358 | - return self::$_engines[$config]->read($settings['prefix'] . $key); |
|
358 | + return self::$_engines[$config]->read($settings['prefix'].$key); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
@@ -373,15 +373,15 @@ discard block |
||
373 | 373 | if (empty($settings)) { |
374 | 374 | return false; |
375 | 375 | } |
376 | - if (!self::isInitialized($config)) { |
|
376 | + if ( ! self::isInitialized($config)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | $key = self::$_engines[$config]->key($key); |
380 | 380 | |
381 | - if (!$key || !is_int($offset) || $offset < 0) { |
|
381 | + if ( ! $key || ! is_int($offset) || $offset < 0) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | - $success = self::$_engines[$config]->increment($settings['prefix'] . $key, $offset); |
|
384 | + $success = self::$_engines[$config]->increment($settings['prefix'].$key, $offset); |
|
385 | 385 | self::set(null, $config); |
386 | 386 | return $success; |
387 | 387 | } |
@@ -401,15 +401,15 @@ discard block |
||
401 | 401 | if (empty($settings)) { |
402 | 402 | return false; |
403 | 403 | } |
404 | - if (!self::isInitialized($config)) { |
|
404 | + if ( ! self::isInitialized($config)) { |
|
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | $key = self::$_engines[$config]->key($key); |
408 | 408 | |
409 | - if (!$key || !is_int($offset) || $offset < 0) { |
|
409 | + if ( ! $key || ! is_int($offset) || $offset < 0) { |
|
410 | 410 | return false; |
411 | 411 | } |
412 | - $success = self::$_engines[$config]->decrement($settings['prefix'] . $key, $offset); |
|
412 | + $success = self::$_engines[$config]->decrement($settings['prefix'].$key, $offset); |
|
413 | 413 | self::set(null, $config); |
414 | 414 | return $success; |
415 | 415 | } |
@@ -437,15 +437,15 @@ discard block |
||
437 | 437 | if (empty($settings)) { |
438 | 438 | return false; |
439 | 439 | } |
440 | - if (!self::isInitialized($config)) { |
|
440 | + if ( ! self::isInitialized($config)) { |
|
441 | 441 | return false; |
442 | 442 | } |
443 | 443 | $key = self::$_engines[$config]->key($key); |
444 | - if (!$key) { |
|
444 | + if ( ! $key) { |
|
445 | 445 | return false; |
446 | 446 | } |
447 | 447 | |
448 | - $success = self::$_engines[$config]->delete($settings['prefix'] . $key); |
|
448 | + $success = self::$_engines[$config]->delete($settings['prefix'].$key); |
|
449 | 449 | self::set(null, $config); |
450 | 450 | return $success; |
451 | 451 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @return boolean True if the cache was successfully cleared, false otherwise |
459 | 459 | */ |
460 | 460 | public static function clear($check = false, $config = 'default') { |
461 | - if (!self::isInitialized($config)) { |
|
461 | + if ( ! self::isInitialized($config)) { |
|
462 | 462 | return false; |
463 | 463 | } |
464 | 464 | $success = self::$_engines[$config]->clear($check); |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | * @return boolean True if the cache group was successfully cleared, false otherwise |
475 | 475 | */ |
476 | 476 | public static function clearGroup($group, $config = 'default') { |
477 | - if (!self::isInitialized($config)) { |
|
477 | + if ( ! self::isInitialized($config)) { |
|
478 | 478 | return false; |
479 | 479 | } |
480 | 480 | $success = self::$_engines[$config]->clearGroup($group); |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @see Cache::config() |
504 | 504 | */ |
505 | 505 | public static function settings($name = 'default') { |
506 | - if (!empty(self::$_engines[$name])) { |
|
506 | + if ( ! empty(self::$_engines[$name])) { |
|
507 | 507 | return self::$_engines[$name]->settings(); |
508 | 508 | } |
509 | 509 | return array(); |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * @see CacheEngine::__defaults |
43 | 43 | */ |
44 | 44 | public function init($settings = array()) { |
45 | - if (!isset($settings['prefix'])) { |
|
46 | - $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; |
|
45 | + if ( ! isset($settings['prefix'])) { |
|
46 | + $settings['prefix'] = Inflector::slug(APP_DIR).'_'; |
|
47 | 47 | } |
48 | 48 | $settings += array('engine' => 'Apc'); |
49 | 49 | parent::init($settings); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | if ($duration) { |
64 | 64 | $expires = time() + $duration; |
65 | 65 | } |
66 | - apc_store($key . '_expires', $expires, $duration); |
|
66 | + apc_store($key.'_expires', $expires, $duration); |
|
67 | 67 | return apc_store($key, $value, $duration); |
68 | 68 | } |
69 | 69 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function read($key) { |
77 | 77 | $time = time(); |
78 | - $cachetime = intval(apc_fetch($key . '_expires')); |
|
78 | + $cachetime = intval(apc_fetch($key.'_expires')); |
|
79 | 79 | if ($cachetime !== 0 && ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime)) { |
80 | 80 | return false; |
81 | 81 | } |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | public function groups() { |
147 | 147 | if (empty($this->_compiledGroupNames)) { |
148 | 148 | foreach ($this->settings['groups'] as $group) { |
149 | - $this->_compiledGroupNames[] = $this->settings['prefix'] . $group; |
|
149 | + $this->_compiledGroupNames[] = $this->settings['prefix'].$group; |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | $groups = apc_fetch($this->_compiledGroupNames); |
154 | 154 | if (count($groups) !== count($this->settings['groups'])) { |
155 | 155 | foreach ($this->_compiledGroupNames as $group) { |
156 | - if (!isset($groups[$group])) { |
|
156 | + if ( ! isset($groups[$group])) { |
|
157 | 157 | apc_store($group, 1); |
158 | 158 | $groups[$group] = 1; |
159 | 159 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $result = array(); |
165 | 165 | $groups = array_values($groups); |
166 | 166 | foreach ($this->settings['groups'] as $i => $group) { |
167 | - $result[] = $group . $groups[$i]; |
|
167 | + $result[] = $group.$groups[$i]; |
|
168 | 168 | } |
169 | 169 | return $result; |
170 | 170 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return boolean success |
177 | 177 | */ |
178 | 178 | public function clearGroup($group) { |
179 | - apc_inc($this->settings['prefix'] . $group, 1, $success); |
|
179 | + apc_inc($this->settings['prefix'].$group, 1, $success); |
|
180 | 180 | return $success; |
181 | 181 | } |
182 | 182 |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | * @return boolean True if the engine has been successfully initialized, false if not |
62 | 62 | */ |
63 | 63 | public function init($settings = array()) { |
64 | - if (!class_exists('Memcache')) { |
|
64 | + if ( ! class_exists('Memcache')) { |
|
65 | 65 | return false; |
66 | 66 | } |
67 | - if (!isset($settings['prefix'])) { |
|
68 | - $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; |
|
67 | + if ( ! isset($settings['prefix'])) { |
|
68 | + $settings['prefix'] = Inflector::slug(APP_DIR).'_'; |
|
69 | 69 | } |
70 | 70 | $settings += array( |
71 | 71 | 'engine' => 'Memcache', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | if (is_string($this->settings['servers'])) { |
82 | 82 | $this->settings['servers'] = array($this->settings['servers']); |
83 | 83 | } |
84 | - if (!isset($this->_Memcache)) { |
|
84 | + if ( ! isset($this->_Memcache)) { |
|
85 | 85 | $return = false; |
86 | 86 | $this->_Memcache = new Memcache(); |
87 | 87 | foreach ($this->settings['servers'] as $server) { |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | } |
208 | 208 | foreach ($this->_Memcache->getExtendedStats('slabs', 0) as $slabs) { |
209 | 209 | foreach (array_keys($slabs) as $slabId) { |
210 | - if (!is_numeric($slabId)) { |
|
210 | + if ( ! is_numeric($slabId)) { |
|
211 | 211 | continue; |
212 | 212 | } |
213 | 213 | |
214 | 214 | foreach ($this->_Memcache->getExtendedStats('cachedump', $slabId, 0) as $stats) { |
215 | - if (!is_array($stats)) { |
|
215 | + if ( ! is_array($stats)) { |
|
216 | 216 | continue; |
217 | 217 | } |
218 | 218 | foreach (array_keys($stats) as $key) { |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | public function groups() { |
254 | 254 | if (empty($this->_compiledGroupNames)) { |
255 | 255 | foreach ($this->settings['groups'] as $group) { |
256 | - $this->_compiledGroupNames[] = $this->settings['prefix'] . $group; |
|
256 | + $this->_compiledGroupNames[] = $this->settings['prefix'].$group; |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | $groups = $this->_Memcache->get($this->_compiledGroupNames); |
261 | 261 | if (count($groups) !== count($this->settings['groups'])) { |
262 | 262 | foreach ($this->_compiledGroupNames as $group) { |
263 | - if (!isset($groups[$group])) { |
|
263 | + if ( ! isset($groups[$group])) { |
|
264 | 264 | $this->_Memcache->set($group, 1, false, 0); |
265 | 265 | $groups[$group] = 1; |
266 | 266 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $result = array(); |
272 | 272 | $groups = array_values($groups); |
273 | 273 | foreach ($this->settings['groups'] as $i => $group) { |
274 | - $result[] = $group . $groups[$i]; |
|
274 | + $result[] = $group.$groups[$i]; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | return $result; |
@@ -284,6 +284,6 @@ discard block |
||
284 | 284 | * @return boolean success |
285 | 285 | */ |
286 | 286 | public function clearGroup($group) { |
287 | - return (bool)$this->_Memcache->increment($this->settings['prefix'] . $group); |
|
287 | + return (bool) $this->_Memcache->increment($this->settings['prefix'].$group); |
|
288 | 288 | } |
289 | 289 | } |