From 4d6d30ae47257e5399cb3d2e7e049f243c4b2a0c Mon Sep 17 00:00:00 2001 From: Fernando Herrero Date: Mon, 23 Oct 2023 12:25:37 +0200 Subject: [PATCH] Compatibility with CakePHP 4.5 --- src/Config/ConfigTrait.php | 67 +------------------ .../Exception/UnallowedDataTypeException.php | 4 +- src/Database/OCI8/OCI8Exception.php | 4 +- src/Database/OracleConnection.php | 4 +- src/Database/Schema/OracleSchema.php | 9 ++- .../Exception/MissingMethodClassException.php | 4 +- src/ORM/Exception/MissingRequestException.php | 4 +- src/TestSuite/Fixture/MethodTestFixture.php | 2 +- 8 files changed, 21 insertions(+), 77 deletions(-) diff --git a/src/Config/ConfigTrait.php b/src/Config/ConfigTrait.php index a502a7c..f1263d6 100644 --- a/src/Config/ConfigTrait.php +++ b/src/Config/ConfigTrait.php @@ -10,7 +10,7 @@ */ namespace CakeDC\OracleDriver\Config; -use Cake\Core\Exception\Exception; +use Cake\Core\Exception\CakeException; use Cake\Utility\Hash; /** @@ -27,67 +27,6 @@ trait ConfigTrait */ protected $_configInitialized = false; - /** - * ### Usage - * - * Reading the whole config: - * - * ``` - * $this->config(); - * ``` - * - * Reading a specific value: - * - * ``` - * $this->config('key'); - * ``` - * - * Reading a nested value: - * - * ``` - * $this->config('some.nested.key'); - * ``` - * - * Setting a specific value: - * - * ``` - * $this->config('key', $value); - * ``` - * - * Setting a nested value: - * - * ``` - * $this->config('some.nested.key', $value); - * ``` - * - * Updating multiple config settings at the same time: - * - * ``` - * $this->config(['one' => 'value', 'another' => 'value']); - * ``` - * - * @param string|array|null $key The key to get/set, or a complete array of configs. - * @param mixed|null $value The value to set. - * @param bool $merge Whether to recursively merge or overwrite existing config, defaults to true. - * @return mixed Config value being read, or the object itself on write operations. - * @throws \Cake\Core\Exception\Exception When trying to set a key that is invalid. - */ - public function config($key = null, $value = null, $merge = true) - { - if (!$this->_configInitialized) { - $this->_config += $this->_baseConfig; - $this->_configInitialized = true; - } - - if (is_array($key) || func_num_args() >= 2) { - $this->_configWrite($key, $value, $merge); - - return $this; - } - - return $this->_configRead($key); - } - /** * Write a config variable * @@ -136,7 +75,7 @@ protected function _configWrite($key, $value, $merge = false) foreach ($stack as $k) { if (!is_array($update)) { - throw new Exception(sprintf('Cannot set %s value', $key)); + throw new CakeException(sprintf('Cannot set %s value', $key)); } if (!isset($update[$k])) { @@ -170,7 +109,7 @@ protected function _configDelete($key) foreach ($stack as $i => $k) { if (!is_array($update)) { - throw new Exception(sprintf('Cannot unset %s value', $key)); + throw new CakeException(sprintf('Cannot unset %s value', $key)); } if (!isset($update[$k])) { diff --git a/src/Database/Exception/UnallowedDataTypeException.php b/src/Database/Exception/UnallowedDataTypeException.php index 51f98c7..006ce02 100644 --- a/src/Database/Exception/UnallowedDataTypeException.php +++ b/src/Database/Exception/UnallowedDataTypeException.php @@ -12,9 +12,9 @@ */ namespace CakeDC\OracleDriver\Database\Exception; -use Cake\Core\Exception\Exception; +use Cake\Core\Exception\CakeException; -class UnallowedDataTypeException extends Exception +class UnallowedDataTypeException extends CakeException { /** * {@inheritDoc} diff --git a/src/Database/OCI8/OCI8Exception.php b/src/Database/OCI8/OCI8Exception.php index 6e16e9b..40e126e 100644 --- a/src/Database/OCI8/OCI8Exception.php +++ b/src/Database/OCI8/OCI8Exception.php @@ -12,9 +12,9 @@ */ namespace CakeDC\OracleDriver\Database\OCI8; -use Cake\Core\Exception\Exception; +use Cake\Core\Exception\CakeException; -class OCI8Exception extends Exception +class OCI8Exception extends CakeException { /** * OCI Error builder. diff --git a/src/Database/OracleConnection.php b/src/Database/OracleConnection.php index e7cbc6a..0002847 100644 --- a/src/Database/OracleConnection.php +++ b/src/Database/OracleConnection.php @@ -12,7 +12,7 @@ */ namespace CakeDC\OracleDriver\Database; -use Cake\Core\Exception\Exception; +use Cake\Core\Exception\CakeException; use Cake\Database\Connection; use Cake\Database\StatementInterface; use CakeDC\OracleDriver\Database\Log\MethodLogger; @@ -91,7 +91,7 @@ public function methodSchemaCollection(?MethodsCollection $collection = null) public function prepareMethod($sql, $options = []) { if (!method_exists($this->_driver, 'isOci') || !$this->_driver->isOci()) { - throw new Exception('Method calls using PDO layer not supported'); + throw new CakeException('Method calls using PDO layer not supported'); } $options += ['bufferResult' => false]; $statement = $this->_driver->prepareMethod($sql, $options); diff --git a/src/Database/Schema/OracleSchema.php b/src/Database/Schema/OracleSchema.php index 65f280a..534d329 100644 --- a/src/Database/Schema/OracleSchema.php +++ b/src/Database/Schema/OracleSchema.php @@ -12,7 +12,7 @@ */ namespace CakeDC\OracleDriver\Database\Schema; -use Cake\Database\Schema\BaseSchema; +use Cake\Database\Schema\SchemaDialect; use Cake\Database\Schema\TableSchema; use Cake\Utility\Hash; use CakeDC\OracleDriver\Database\Exception\UnallowedDataTypeException; @@ -20,7 +20,7 @@ /** * Schema management/reflection features for Oracle. */ -class OracleSchema extends BaseSchema +class OracleSchema extends SchemaDialect { protected $_constraints = []; @@ -233,6 +233,7 @@ public function convertColumnDescription(TableSchema $schema, array $row): void break; case 'NCLOB': case 'CLOB': + case 'XMLTYPE': $field = [ 'type' => TableSchema::TYPE_TEXT, 'length' => $row['char_length'], @@ -482,6 +483,10 @@ public function convertIndexDescription(TableSchema $schema, array $row): void $type = null; $columns = $length = []; + if (preg_match('~FUNCTION-BASED~i', ($tableIndex['type'] ?? ''))) { + return; + } + $keyName = $this->_transformValueCase($tableIndex['name']); $name = $this->_transformValueCase($tableIndex['column_name']); if ( !empty($tableIndex['is_primary']) && strtolower($tableIndex['is_primary']) === 'p') { diff --git a/src/ORM/Exception/MissingMethodClassException.php b/src/ORM/Exception/MissingMethodClassException.php index d761fc3..ff09f22 100644 --- a/src/ORM/Exception/MissingMethodClassException.php +++ b/src/ORM/Exception/MissingMethodClassException.php @@ -12,13 +12,13 @@ */ namespace CakeDC\OracleDriver\ORM\Exception; -use Cake\Core\Exception\Exception; +use Cake\Core\Exception\CakeException; /** * Exception raised when a Table could not be found. * */ -class MissingMethodClassException extends Exception +class MissingMethodClassException extends CakeException { protected $_messageTemplate = 'Method class %s could not be found.'; } diff --git a/src/ORM/Exception/MissingRequestException.php b/src/ORM/Exception/MissingRequestException.php index c5ee251..350b20d 100644 --- a/src/ORM/Exception/MissingRequestException.php +++ b/src/ORM/Exception/MissingRequestException.php @@ -12,13 +12,13 @@ */ namespace CakeDC\OracleDriver\ORM\Exception; -use Cake\Core\Exception\Exception; +use Cake\Core\Exception\CakeException; /** * Exception raised when an Request could not be found. * */ -class MissingRequestException extends Exception +class MissingRequestException extends CakeException { protected $_messageTemplate = 'Request class %s could not be found.'; } diff --git a/src/TestSuite/Fixture/MethodTestFixture.php b/src/TestSuite/Fixture/MethodTestFixture.php index 3a82ac6..d9f985f 100644 --- a/src/TestSuite/Fixture/MethodTestFixture.php +++ b/src/TestSuite/Fixture/MethodTestFixture.php @@ -12,7 +12,7 @@ */ namespace CakeDC\OracleDriver\TestSuite\Fixture; -use Cake\Core\Exception\Exception as CakeException; +use Cake\Core\Exception\CakeException; use Cake\Datasource\ConnectionInterface; use Cake\Log\Log; use Cake\Utility\Inflector;