Skip to content

Commit e40ee25

Browse files
committed
Minor optimization in h()
Minor optimizations in FormHelper, as calls to ArrayAccess methods are avoided now.
1 parent 7bfdbff commit e40ee25

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

cake/basics.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,7 @@ function h($text, $double = true, $charset = null) {
186186
if (is_string($double)) {
187187
$charset = $double;
188188
}
189-
if ($charset) {
190-
return htmlspecialchars($text, ENT_QUOTES, $charset, $double);
191-
} else {
192-
return htmlspecialchars($text, ENT_QUOTES, $defaultCharset, $double);
193-
}
189+
return htmlspecialchars($text, ENT_QUOTES, ($charset) ? $charset : $defaultCharset, $double);
194190
}
195191

196192
/**

cake/libs/view/helpers/form.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ function create($model = null, $options = array()) {
243243
if (empty($options['url']['controller'])) {
244244
if (!empty($model) && $model != $this->defaultModel) {
245245
$options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model));
246-
} elseif (!empty($this->request['controller'])) {
247-
$options['url']['controller'] = Inflector::underscore($this->request['controller']);
246+
} elseif (!empty($this->request->params['controller'])) {
247+
$options['url']['controller'] = Inflector::underscore($this->request->params['controller']);
248248
}
249249
}
250250
if (empty($options['action'])) {
251-
$options['action'] = $this->request['action'];
251+
$options['action'] = $this->request->params['action'];
252252
}
253253

254254
$actionDefaults = array(
@@ -307,9 +307,9 @@ function create($model = null, $options = array()) {
307307
$htmlAttributes = array_merge($options, $htmlAttributes);
308308

309309
$this->fields = array();
310-
if (isset($this->request['_Token']) && !empty($this->request['_Token'])) {
310+
if (isset($this->request->params['_Token']) && !empty($this->request->params['_Token'])) {
311311
$append .= $this->hidden('_Token.key', array(
312-
'value' => $this->request['_Token']['key'], 'id' => 'Token' . mt_rand())
312+
'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand())
313313
);
314314
}
315315

0 commit comments

Comments
 (0)