Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with CakePHP 4.5 (PHP-7.4) #73

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 3 additions & 64 deletions src/Config/ConfigTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
namespace CakeDC\OracleDriver\Config;

use Cake\Core\Exception\Exception;
use Cake\Core\Exception\CakeException;
use Cake\Utility\Hash;

/**
Expand All @@ -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
*
Expand Down Expand Up @@ -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])) {
Expand Down Expand Up @@ -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])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Database/Exception/UnallowedDataTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions src/Database/OCI8/OCI8Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/Database/OracleConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions src/Database/Schema/OracleSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
*/
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;

/**
* Schema management/reflection features for Oracle.
*/
class OracleSchema extends BaseSchema
class OracleSchema extends SchemaDialect
{
protected $_constraints = [];

Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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') {
Expand Down
4 changes: 2 additions & 2 deletions src/ORM/Exception/MissingMethodClassException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
4 changes: 2 additions & 2 deletions src/ORM/Exception/MissingRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
}
2 changes: 1 addition & 1 deletion src/TestSuite/Fixture/MethodTestFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down