From 5411363dc2a60302034898dfd5cd9cc1356ff42c Mon Sep 17 00:00:00 2001 From: Kevin Dees Date: Sat, 6 Aug 2022 20:03:39 -0400 Subject: [PATCH] update typerocket core --- typerocket-v5.php | 4 +-- typerocket/composer.lock | 12 ++++----- typerocket/vendor/composer/installed.json | 14 +++++------ typerocket/vendor/composer/installed.php | 10 ++++---- .../core/src/Database/Connection.php | 4 +++ .../typerocket/core/src/Database/Query.php | 3 +-- .../typerocket/core/src/Models/Model.php | 25 +++++++++++++------ 7 files changed, 42 insertions(+), 30 deletions(-) diff --git a/typerocket-v5.php b/typerocket-v5.php index 065c4683..b1d334f1 100644 --- a/typerocket-v5.php +++ b/typerocket-v5.php @@ -3,7 +3,7 @@ Plugin Name: TypeRocket - Andromeda Plugin URI: https://typerocket.com/ Description: TypeRocket is a framework that joins refined UI elements and modern programming architecture together. -Version: 5.1.5 +Version: 5.1.6 Requires at least: 6.0 Requires PHP: 7.4 Author: TypeRocket @@ -34,7 +34,7 @@ public function __construct() return; } - define('TYPEROCKET_PLUGIN_VERSION', '5.1.5'); + define('TYPEROCKET_PLUGIN_VERSION', '5.1.6'); define('TYPEROCKET_PLUGIN_INSTALL', __DIR__); if(!defined('TYPEROCKET_ROOT_WP')) diff --git a/typerocket/composer.lock b/typerocket/composer.lock index 425293c2..bdabdccf 100644 --- a/typerocket/composer.lock +++ b/typerocket/composer.lock @@ -883,16 +883,16 @@ }, { "name": "typerocket/core", - "version": "v5.1.11", + "version": "v5.1.13", "source": { "type": "git", "url": "https://github.com/TypeRocket/core.git", - "reference": "bac282d3abab5c919ec543bc84a2ab12ab1e8a4f" + "reference": "82c0b73cbd39aa3f87d734e8d9f5008672843adc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TypeRocket/core/zipball/bac282d3abab5c919ec543bc84a2ab12ab1e8a4f", - "reference": "bac282d3abab5c919ec543bc84a2ab12ab1e8a4f", + "url": "https://api.github.com/repos/TypeRocket/core/zipball/82c0b73cbd39aa3f87d734e8d9f5008672843adc", + "reference": "82c0b73cbd39aa3f87d734e8d9f5008672843adc", "shasum": "" }, "require": { @@ -933,9 +933,9 @@ "support": { "docs": "https://typerocket.com/docs/v5/", "issues": "https://github.com/TypeRocket/core/issues", - "source": "https://github.com/TypeRocket/core/tree/v5.1.11" + "source": "https://github.com/TypeRocket/core/tree/v5.1.13" }, - "time": "2022-08-04T14:21:35+00:00" + "time": "2022-08-06T23:52:14+00:00" }, { "name": "woocommerce/action-scheduler", diff --git a/typerocket/vendor/composer/installed.json b/typerocket/vendor/composer/installed.json index 8c340645..cd5a032b 100644 --- a/typerocket/vendor/composer/installed.json +++ b/typerocket/vendor/composer/installed.json @@ -2963,17 +2963,17 @@ }, { "name": "typerocket/core", - "version": "v5.1.11", - "version_normalized": "5.1.11.0", + "version": "v5.1.13", + "version_normalized": "5.1.13.0", "source": { "type": "git", "url": "https://github.com/TypeRocket/core.git", - "reference": "bac282d3abab5c919ec543bc84a2ab12ab1e8a4f" + "reference": "82c0b73cbd39aa3f87d734e8d9f5008672843adc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TypeRocket/core/zipball/bac282d3abab5c919ec543bc84a2ab12ab1e8a4f", - "reference": "bac282d3abab5c919ec543bc84a2ab12ab1e8a4f", + "url": "https://api.github.com/repos/TypeRocket/core/zipball/82c0b73cbd39aa3f87d734e8d9f5008672843adc", + "reference": "82c0b73cbd39aa3f87d734e8d9f5008672843adc", "shasum": "" }, "require": { @@ -2987,7 +2987,7 @@ "require-dev": { "phpunit/phpunit": "^9.5" }, - "time": "2022-08-04T14:21:35+00:00", + "time": "2022-08-06T23:52:14+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -3016,7 +3016,7 @@ "support": { "docs": "https://typerocket.com/docs/v5/", "issues": "https://github.com/TypeRocket/core/issues", - "source": "https://github.com/TypeRocket/core/tree/v5.1.11" + "source": "https://github.com/TypeRocket/core/tree/v5.1.13" }, "install-path": "../typerocket/core" }, diff --git a/typerocket/vendor/composer/installed.php b/typerocket/vendor/composer/installed.php index bcb6556c..e9debad0 100644 --- a/typerocket/vendor/composer/installed.php +++ b/typerocket/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '652a3e6b6031e275fee0c4cdcbad4e54831dbe56', + 'reference' => '8621516a9ea1675c3b4b34631733edeb49f4df5b', 'name' => 'typerocket/typerocket', 'dev' => true, ), @@ -404,12 +404,12 @@ 'dev_requirement' => true, ), 'typerocket/core' => array( - 'pretty_version' => 'v5.1.11', - 'version' => '5.1.11.0', + 'pretty_version' => 'v5.1.13', + 'version' => '5.1.13.0', 'type' => 'library', 'install_path' => __DIR__ . '/../typerocket/core', 'aliases' => array(), - 'reference' => 'bac282d3abab5c919ec543bc84a2ab12ab1e8a4f', + 'reference' => '82c0b73cbd39aa3f87d734e8d9f5008672843adc', 'dev_requirement' => false, ), 'typerocket/typerocket' => array( @@ -418,7 +418,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '652a3e6b6031e275fee0c4cdcbad4e54831dbe56', + 'reference' => '8621516a9ea1675c3b4b34631733edeb49f4df5b', 'dev_requirement' => false, ), 'webmozart/assert' => array( diff --git a/typerocket/vendor/typerocket/core/src/Database/Connection.php b/typerocket/vendor/typerocket/core/src/Database/Connection.php index a1664b63..55c5548c 100644 --- a/typerocket/vendor/typerocket/core/src/Database/Connection.php +++ b/typerocket/vendor/typerocket/core/src/Database/Connection.php @@ -49,6 +49,10 @@ public function addFromConfig(?string $name, ?array $config = null) if(is_null($config) || is_null($name)) { $drivers = Config::getFromContainer()->locate('database.drivers'); $config = $drivers[$name] ?? Config::getFromContainer()->locate('database.default'); + + if($name && !$drivers && !$config) { + throw new \Error(__("TypeRocket database connection configuration not found for \"{$name}\"", 'typerocket-core')); + } } /** @var DatabaseConnector $connector */ diff --git a/typerocket/vendor/typerocket/core/src/Database/Query.php b/typerocket/vendor/typerocket/core/src/Database/Query.php index 00c9c1ed..6edeea6c 100644 --- a/typerocket/vendor/typerocket/core/src/Database/Query.php +++ b/typerocket/vendor/typerocket/core/src/Database/Query.php @@ -53,9 +53,8 @@ public function __construct($table = null, $selectTable = null, $idColumn = null protected function establishConnection() { $connection = Connection::getFromContainer(); - $name = $this->connection; - if(!is_string($name) || !$connection->exists($name)) { + if(!$name = $this->connection) { return $connection->default(); } diff --git a/typerocket/vendor/typerocket/core/src/Models/Model.php b/typerocket/vendor/typerocket/core/src/Models/Model.php index 5634c4b9..1dad54ff 100644 --- a/typerocket/vendor/typerocket/core/src/Models/Model.php +++ b/typerocket/vendor/typerocket/core/src/Models/Model.php @@ -260,7 +260,7 @@ protected function establishConnection() $connection = Connection::getFromContainer(); $name = $this->connection; - if(!is_string($name) || !$connection->exists($name)) { + if(!$name) { return $connection->default(); } @@ -1967,15 +1967,14 @@ public function getCast( $property ) */ public function hasOne($modelClass, $id_foreign = null, $scope = null) { - $id = $this->getID(); + /** @var Model $relationship */ + $relationship = new $modelClass; + $relationship->setRelatedModel( $this ); if( ! $id_foreign && $this->resource ) { $id_foreign = $this->resource . '_id'; } - /** @var Model $relationship */ - $relationship = new $modelClass; - $relationship->setRelatedModel( $this ); $relationship->relatedBy = [ 'type' => 'hasOne', 'query' => [ @@ -1986,7 +1985,12 @@ public function hasOne($modelClass, $id_foreign = null, $scope = null) ] ]; - return $relationship->findAll()->where( $id_foreign, $id)->take(1); + if(is_callable($scope)) { + $scope($relationship); + } + + $id = $this->getID(); + return $relationship->where( $id_foreign, $id)->take(1); } /** @@ -2003,6 +2007,11 @@ public function belongsTo($modelClass, $id_local = null, $scope = null) /** @var Model $relationship */ $relationship = new $modelClass; $relationship->setRelatedModel( $this ); + + if( ! $id_local && $relationship->resource ) { + $id_local = $relationship->resource . '_id'; + } + $relationship->relatedBy = [ 'type' => 'belongsTo', 'query' => [ @@ -2013,8 +2022,8 @@ public function belongsTo($modelClass, $id_local = null, $scope = null) ] ]; - if( ! $id_local && $relationship->resource ) { - $id_local = $relationship->resource . '_id'; + if(is_callable($scope)) { + $scope($relationship); } $id = $this->getProperty( $id_local );