Skip to content

Commit aebc511

Browse files
committed
update typerocket core and bump version 5.1.13
1 parent e1870cd commit aebc511

File tree

8 files changed

+75
-41
lines changed

8 files changed

+75
-41
lines changed

typerocket-v5.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: TypeRocket - Andromeda
44
Plugin URI: https://typerocket.com/
55
Description: TypeRocket is a framework that joins refined UI elements and modern programming architecture together.
6-
Version: 5.1.13
6+
Version: 5.1.14
77
Requires at least: 6.0
88
Requires PHP: 7.4
99
Author: TypeRocket
@@ -34,7 +34,7 @@ public function __construct()
3434
return;
3535
}
3636

37-
define('TYPEROCKET_PLUGIN_VERSION', '5.1.13');
37+
define('TYPEROCKET_PLUGIN_VERSION', '5.1.14');
3838
define('TYPEROCKET_PLUGIN_INSTALL', __DIR__);
3939

4040
if(!defined('TYPEROCKET_ROOT_WP'))

typerocket/composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typerocket/helpers.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ function tr_components_loop($builder_data, $other = [], $group = 'builder')
407407
*/
408408
function tr_show_page_builder(string $field_name = "use_builder", $item_id = null)
409409
{
410-
$use_builder = tr_post_field(...func_get_args());
410+
$args = func_get_args() ?: [$field_name];
411+
$use_builder = tr_post_field(...$args);
411412
return $use_builder === '1' || $use_builder === 1 && !post_password_required();
412413
}
413414

typerocket/vendor/composer/installed.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,17 +2720,17 @@
27202720
},
27212721
{
27222722
"name": "typerocket/core",
2723-
"version": "v5.1.37",
2724-
"version_normalized": "5.1.37.0",
2723+
"version": "v5.1.40",
2724+
"version_normalized": "5.1.40.0",
27252725
"source": {
27262726
"type": "git",
27272727
"url": "https://github.com/TypeRocket/core.git",
2728-
"reference": "719408206172763b84dea589571b5150afa2f609"
2728+
"reference": "756fe9c5b3dca0ae2c0e9731c9d42293f47f44ad"
27292729
},
27302730
"dist": {
27312731
"type": "zip",
2732-
"url": "https://api.github.com/repos/TypeRocket/core/zipball/719408206172763b84dea589571b5150afa2f609",
2733-
"reference": "719408206172763b84dea589571b5150afa2f609",
2732+
"url": "https://api.github.com/repos/TypeRocket/core/zipball/756fe9c5b3dca0ae2c0e9731c9d42293f47f44ad",
2733+
"reference": "756fe9c5b3dca0ae2c0e9731c9d42293f47f44ad",
27342734
"shasum": ""
27352735
},
27362736
"require": {
@@ -2744,7 +2744,7 @@
27442744
"require-dev": {
27452745
"phpunit/phpunit": "^9.5"
27462746
},
2747-
"time": "2022-09-07T19:54:00+00:00",
2747+
"time": "2022-09-08T01:23:37+00:00",
27482748
"type": "library",
27492749
"installation-source": "dist",
27502750
"autoload": {
@@ -2773,7 +2773,7 @@
27732773
"support": {
27742774
"docs": "https://typerocket.com/docs/v5/",
27752775
"issues": "https://github.com/TypeRocket/core/issues",
2776-
"source": "https://github.com/TypeRocket/core/tree/v5.1.37"
2776+
"source": "https://github.com/TypeRocket/core/tree/v5.1.40"
27772777
},
27782778
"install-path": "../typerocket/core"
27792779
},

typerocket/vendor/composer/installed.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'typerocket/typerocket',
44
'pretty_version' => 'dev-main',
55
'version' => 'dev-main',
6-
'reference' => '5cf578426d2f799bc7448fd3cc035723ea45ea64',
6+
'reference' => 'e1870cd73275dedf99bb6488e1247e38b367923b',
77
'type' => 'library',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -368,9 +368,9 @@
368368
'dev_requirement' => true,
369369
),
370370
'typerocket/core' => array(
371-
'pretty_version' => 'v5.1.37',
372-
'version' => '5.1.37.0',
373-
'reference' => '719408206172763b84dea589571b5150afa2f609',
371+
'pretty_version' => 'v5.1.40',
372+
'version' => '5.1.40.0',
373+
'reference' => '756fe9c5b3dca0ae2c0e9731c9d42293f47f44ad',
374374
'type' => 'library',
375375
'install_path' => __DIR__ . '/../typerocket/core',
376376
'aliases' => array(),
@@ -379,7 +379,7 @@
379379
'typerocket/typerocket' => array(
380380
'pretty_version' => 'dev-main',
381381
'version' => 'dev-main',
382-
'reference' => '5cf578426d2f799bc7448fd3cc035723ea45ea64',
382+
'reference' => 'e1870cd73275dedf99bb6488e1247e38b367923b',
383383
'type' => 'library',
384384
'install_path' => __DIR__ . '/../../',
385385
'aliases' => array(),

typerocket/vendor/typerocket/core/src/Database/Query.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public function lastWhere() : ?array
312312
*
313313
* @return $this
314314
*/
315-
public function modifyWhere($index, $args, $merge = true)
315+
public function modifyWhere($index, $args, $merge = true, $callback = null)
316316
{
317317
if(empty($this->query['where'])) {
318318
return $this;
@@ -322,7 +322,13 @@ public function modifyWhere($index, $args, $merge = true)
322322
$index = array_key_last($this->query['where']);
323323
}
324324

325-
$this->query['where'][$index] = $merge ? array_merge($this->query['where'][$index], $args) : $args;
325+
$where = $merge ? array_merge($this->query['where'][$index], $args) : $args;
326+
327+
if(is_callable($callback)) {
328+
$callback($where, $this, $index);
329+
}
330+
331+
$this->query['where'][$index] = $where;
326332

327333
return $this;
328334
}

typerocket/vendor/typerocket/core/src/Models/Model.php

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class Model implements Formable, JsonSerializable
173173
/**
174174
* @var array
175175
*/
176-
#[ArrayShape(['type' => 'string', 'query' => 'array'])]
176+
#[ArrayShape(['type' => 'string', 'query' => 'array', 'where_on' => 'array'])]
177177
protected $relatedBy;
178178

179179
/**
@@ -1661,7 +1661,6 @@ public function whereRelationship(string $relationship, bool $exists, $scope = n
16611661
throw new \Exception("Trying to get relationship of '{$relationship}' but no Model class is returned for " . get_class($this));
16621662
}
16631663

1664-
$junction = $rel->getJunction();
16651664
$related = $rel->getRelatedBy();
16661665
$id_column = null;
16671666
$where_on_index = -1;
@@ -2052,12 +2051,14 @@ public function getCast( $property )
20522051
/**
20532052
* Has One
20542053
*
2055-
* @param string $modelClass
2054+
* @template M
2055+
*
2056+
* @param class-string<M> $modelClass
20562057
* @param null|string $id_foreign
20572058
* @param null|string|callable $id_local
20582059
* @param null|callable $scope
20592060
*
2060-
* @return null|Model
2061+
* @return null|Model|M
20612062
*/
20622063
public function hasOne($modelClass, $id_foreign = null, $id_local = null, $scope = null)
20632064
{
@@ -2091,8 +2092,12 @@ public function hasOne($modelClass, $id_foreign = null, $id_local = null, $scope
20912092
$scope($relationship);
20922093
}
20932094

2095+
$rel_table = $relationship->getTable();
2096+
$id_foreign = $id_foreign ?? $relationship->getIdColumn();
2097+
$id_foreign_where = str_contains($id_foreign, '.') ? $id_foreign : "{$rel_table}.$id_foreign";
2098+
20942099
$id = $this->getPropertyValueDirect($id_local);
2095-
$result = $relationship->where( $id_foreign, $id)->take(1);
2100+
$result = $relationship->where($id_foreign_where, $id)->take(1);
20962101
$relationship->relatedBy['where_on'] = $relationship->getQuery()->lastWhere();
20972102

20982103
return $result;
@@ -2101,12 +2106,14 @@ public function hasOne($modelClass, $id_foreign = null, $id_local = null, $scope
21012106
/**
21022107
* Belongs To
21032108
*
2104-
* @param string $modelClass
2109+
* @template M
2110+
*
2111+
* @param class-string<M> $modelClass
21052112
* @param null|string $id_local
21062113
* @param null|string|callable $id_foreign
21072114
* @param null|callable $scope
21082115
*
2109-
* @return null|Model
2116+
* @return null|Model|M
21102117
*/
21112118
public function belongsTo($modelClass, $id_local = null, $id_foreign = null, $scope = null)
21122119
{
@@ -2119,6 +2126,8 @@ public function belongsTo($modelClass, $id_local = null, $id_foreign = null, $sc
21192126
$id_foreign = $relationship->getIdColumn();
21202127
} elseif(is_null($id_foreign) && is_null($scope)) {
21212128
$id_foreign = $relationship->getIdColumn();
2129+
} else {
2130+
$id_foreign = $id_foreign ?? $relationship->getIdColumn();
21222131
}
21232132

21242133
if( ! $id_local && $relationship->resource ) {
@@ -2141,7 +2150,11 @@ public function belongsTo($modelClass, $id_local = null, $id_foreign = null, $sc
21412150
}
21422151

21432152
$id = $this->getProperty( $id_local );
2144-
$result = $relationship->where( $id_foreign ?? $relationship->getIdColumn(), $id)->take(1);
2153+
2154+
$rel_table = $relationship->getTable();
2155+
$id_foreign_where = str_contains($id_foreign, '.') ? $id_foreign : "{$rel_table}.$id_foreign";
2156+
2157+
$result = $relationship->where($id_foreign_where, $id)->take(1);
21452158
$relationship->relatedBy['where_on'] = $relationship->getQuery()->lastWhere();
21462159

21472160
return $result;
@@ -2150,12 +2163,14 @@ public function belongsTo($modelClass, $id_local = null, $id_foreign = null, $sc
21502163
/**
21512164
* Has Many
21522165
*
2153-
* @param string $modelClass
2166+
* @template M
2167+
*
2168+
* @param class-string<M> $modelClass
21542169
* @param null|string $id_foreign
21552170
* @param null|string|callable $id_local
21562171
* @param null|callable $scope
21572172
*
2158-
* @return null|Model
2173+
* @return null|Model|M
21592174
*/
21602175
public function hasMany($modelClass, $id_foreign = null, $id_local = null, $scope = null)
21612176
{
@@ -2190,7 +2205,10 @@ public function hasMany($modelClass, $id_foreign = null, $id_local = null, $scop
21902205
$scope($relationship);
21912206
}
21922207

2193-
$result = $relationship->findAll()->where( $id_foreign, $id );
2208+
$rel_table = $relationship->getTable();
2209+
$id_foreign_where = str_contains($id_foreign, '.') ? $id_foreign : "{$rel_table}.$id_foreign";
2210+
2211+
$result = $relationship->findAll()->where( $id_foreign_where, $id );
21942212
$relationship->relatedBy['where_on'] = $relationship->getQuery()->lastWhere();
21952213

21962214
return $result;
@@ -2201,14 +2219,16 @@ public function hasMany($modelClass, $id_foreign = null, $id_local = null, $scop
22012219
*
22022220
* This is for Many-to-Many relationships.
22032221
*
2204-
* @param string|array $modelClass
2222+
* @template M
2223+
*
2224+
* @param class-string<M> $modelClass
22052225
* @param string $junction_table
22062226
* @param null|string $id_column
22072227
* @param null|string $id_foreign
22082228
* @param null|callable $scope
22092229
* @param bool $reselect
22102230
*
2211-
* @return null|Model
2231+
* @return null|Model|M
22122232
*/
22132233
public function belongsToMany( $modelClass, $junction_table, $id_column = null, $id_foreign = null, $scope = null, $reselect = true, $id_local = null, $id_foreign_local = null )
22142234
{
@@ -2293,7 +2313,7 @@ public function belongsToMany( $modelClass, $junction_table, $id_column = null,
22932313
*
22942314
* @param array $args
22952315
*
2296-
* @return array $query
2316+
* @return array{0: mixed, 1: Query}
22972317
*/
22982318
public function attach( array $args )
22992319
{
@@ -2329,7 +2349,7 @@ public function attach( array $args )
23292349
*
23302350
* @param array $args
23312351
*
2332-
* @return array
2352+
* @return array{0: mixed, 1: Query}
23332353
*/
23342354
public function detach( array $args = [] )
23352355
{
@@ -2357,7 +2377,7 @@ public function detach( array $args = [] )
23572377
*
23582378
* @param array $args
23592379
*
2360-
* @return array $results
2380+
* @return array{detach: array{0: mixed, 1: Query}, attach: array{0: mixed, 1: Query}}
23612381
*/
23622382
public function sync( array $args = [] )
23632383
{
@@ -2371,13 +2391,13 @@ public function sync( array $args = [] )
23712391
/**
23722392
* Get Table
23732393
*
2374-
* @return null
2394+
* @return string
23752395
*/
23762396
public function getTable()
23772397
{
23782398
$connection = $this->query->getWpdb();
23792399

2380-
return $this->table ?: $connection->prefix . $this->resource;
2400+
return $this->table ?: $connection->prefix . $this->resource;
23812401
}
23822402

23832403
/**

typerocket/vendor/typerocket/core/src/Utility/Jobs/Queue.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,17 @@ public static function registerJob(string $jobClass)
145145
/**
146146
* @param JobCanQueue $job
147147
* @param null|int $time
148+
*
148149
* @return int
149150
*/
150151
public static function addJob(JobCanQueue $job, $time = null)
151152
{
153+
if(Config::getFromContainer()->locate('queue.mode') === 'sync') {
154+
$job->handle();
155+
156+
return -1;
157+
}
158+
152159
$class = get_class($job);
153160
$time = $time ?? (time() + $job::DELAY);
154161
$actionName = 'typerocket_job.' . $class;

0 commit comments

Comments
 (0)