mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
commit
300f245160
3 changed files with 14 additions and 5 deletions
|
@ -333,7 +333,7 @@ class Mysql extends DboSource {
|
|||
* Returns an array of the fields in given table name.
|
||||
*
|
||||
* @param Model|string $model Name of database table to inspect or model instance
|
||||
* @return array Fields in table. Keys are name and type
|
||||
* @return array|bool Fields in table. Keys are name and type. Returns false if result is empty.
|
||||
* @throws CakeException
|
||||
*/
|
||||
public function describe($model) {
|
||||
|
@ -344,7 +344,7 @@ class Mysql extends DboSource {
|
|||
}
|
||||
$table = $this->fullTableName($model);
|
||||
|
||||
$fields = false;
|
||||
$fields = array();
|
||||
$cols = $this->_execute('SHOW FULL COLUMNS FROM ' . $table);
|
||||
if (!$cols) {
|
||||
throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table));
|
||||
|
@ -361,7 +361,8 @@ class Mysql extends DboSource {
|
|||
$fields[$column->Field]['unsigned'] = $this->_unsigned($column->Type);
|
||||
}
|
||||
if (in_array($fields[$column->Field]['type'], array('timestamp', 'datetime')) &&
|
||||
in_array(strtoupper($column->Default), array('CURRENT_TIMESTAMP', 'CURRENT_TIMESTAMP()'))
|
||||
//Falling back to default empty string due to PHP8.1 deprecation notice.
|
||||
in_array(strtoupper($column->Default ?? ""), array('CURRENT_TIMESTAMP', 'CURRENT_TIMESTAMP()'))
|
||||
) {
|
||||
$fields[$column->Field]['default'] = null;
|
||||
}
|
||||
|
@ -382,6 +383,12 @@ class Mysql extends DboSource {
|
|||
}
|
||||
$this->_cacheDescription($key, $fields);
|
||||
$cols->closeCursor();
|
||||
|
||||
//Fields must be an array for compatibility with PHP8.1 (deprecation notice) but also let's keep backwards compatibility for method.
|
||||
if (count($fields) === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
|
|
@ -2070,7 +2070,8 @@ class DboSource extends DataSource {
|
|||
* @return string
|
||||
*/
|
||||
public function renderJoinStatement($data) {
|
||||
if (strtoupper($data['type']) === 'CROSS' || empty($data['conditions'])) {
|
||||
//Fixed deprecation notice in PHP8.1 - fallback to empty string
|
||||
if (strtoupper($data['type'] ?? "") === 'CROSS' || empty($data['conditions'])) {
|
||||
return "{$data['type']} JOIN {$data['table']} {$data['alias']}";
|
||||
}
|
||||
return trim("{$data['type']} JOIN {$data['table']} {$data['alias']} ON ({$data['conditions']})");
|
||||
|
|
|
@ -470,7 +470,8 @@ class CakeRoute {
|
|||
//check patterns for routed params
|
||||
if (!empty($this->options)) {
|
||||
foreach ($this->options as $key => $pattern) {
|
||||
if (array_key_exists($key, $url) && !preg_match('#^' . $pattern . '$#', $url[$key])) {
|
||||
//Fixing deprecation notice about null $subject in PHP8.1.
|
||||
if (array_key_exists($key, $url) && !preg_match('#^' . $pattern . '$#', $url[$key] ?? "")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue