Merge pull request #12487 from josephzidell/php_7.3_issues

Fixes: a few issues found when running PHP 7.3
This commit is contained in:
Mark Story 2018-09-09 12:50:23 -04:00 committed by GitHub
commit 2bea29d07c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 6 deletions

View file

@ -940,7 +940,7 @@ class DboSource extends DataSource {
) )
); );
} }
if (preg_match('/^[\w-_\s]*[\w-_]+/', $data)) { if (preg_match('/^[\w\-_\s]*[\w\-_]+/', $data)) {
return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote); return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote);
} }
return $this->cacheMethod(__FUNCTION__, $cacheKey, $data); return $this->cacheMethod(__FUNCTION__, $cacheKey, $data);

View file

@ -303,7 +303,7 @@ class CakeRequest implements ArrayAccess {
return $this->base = $base; return $this->base = $base;
} }
if (!$baseUrl) { if (empty($baseUrl)) {
$base = dirname(env('PHP_SELF')); $base = dirname(env('PHP_SELF'));
// Clean up additional / which cause following code to fail.. // Clean up additional / which cause following code to fail..
$base = preg_replace('#/+#', '/', $base); $base = preg_replace('#/+#', '/', $base);

View file

@ -1162,13 +1162,13 @@ class CakeResponse {
public function checkNotModified(CakeRequest $request) { public function checkNotModified(CakeRequest $request) {
$etags = preg_split('/\s*,\s*/', $request->header('If-None-Match'), null, PREG_SPLIT_NO_EMPTY); $etags = preg_split('/\s*,\s*/', $request->header('If-None-Match'), null, PREG_SPLIT_NO_EMPTY);
$modifiedSince = $request->header('If-Modified-Since'); $modifiedSince = $request->header('If-Modified-Since');
$checks = array();
if ($responseTag = $this->etag()) { if ($responseTag = $this->etag()) {
$etagMatches = in_array('*', $etags) || in_array($responseTag, $etags); $checks[] = in_array('*', $etags) || in_array($responseTag, $etags);
} }
if ($modifiedSince) { if ($modifiedSince) {
$timeMatches = strtotime($this->modified()) === strtotime($modifiedSince); $checks[] = strtotime($this->modified()) === strtotime($modifiedSince);
} }
$checks = compact('etagMatches', 'timeMatches');
if (empty($checks)) { if (empty($checks)) {
return false; return false;
} }

View file

@ -95,6 +95,7 @@ abstract class ObjectCollection {
if (empty($this->_enabled)) { if (empty($this->_enabled)) {
return true; return true;
} }
$subject = null;
if ($callback instanceof CakeEvent) { if ($callback instanceof CakeEvent) {
$event = $callback; $event = $callback;
if (is_array($event->data)) { if (is_array($event->data)) {
@ -125,7 +126,7 @@ abstract class ObjectCollection {
} }
$result = null; $result = null;
foreach ($list as $name) { foreach ($list as $name) {
$result = call_user_func_array(array($this->_loaded[$name], $callback), compact('subject') + $params); $result = call_user_func_array(array($this->_loaded[$name], $callback), array_filter(compact('subject')) + $params);
if ($options['collectReturn'] === true) { if ($options['collectReturn'] === true) {
$collected[] = $result; $collected[] = $result;
} }

View file

@ -1060,6 +1060,8 @@ class FormHelper extends AppHelper {
if ($options['type'] === 'radio' && isset($options['options'])) { if ($options['type'] === 'radio' && isset($options['options'])) {
$radioOptions = (array)$options['options']; $radioOptions = (array)$options['options'];
unset($options['options']); unset($options['options']);
} else {
$radioOptions = [];
} }
$label = $this->_getLabel($fieldName, $options); $label = $this->_getLabel($fieldName, $options);
@ -1080,6 +1082,9 @@ class FormHelper extends AppHelper {
$dateFormat = $this->_extractOption('dateFormat', $options, 'MDY'); $dateFormat = $this->_extractOption('dateFormat', $options, 'MDY');
$timeFormat = $this->_extractOption('timeFormat', $options, 12); $timeFormat = $this->_extractOption('timeFormat', $options, 12);
unset($options['dateFormat'], $options['timeFormat']); unset($options['dateFormat'], $options['timeFormat']);
} else {
$dateFormat = 'MDY';
$timeFormat = 12;
} }
$type = $options['type']; $type = $options['type'];