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

3.6.6 #4300

Merged
merged 22 commits into from
May 5, 2022
Merged

3.6.6 #4300

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3c8f355
Support Obj->get([array])
adamkiss Apr 11, 2022
4f9c6be
Support A::random()
adamkiss Apr 11, 2022
4e87786
Support $collection->random()
adamkiss Apr 11, 2022
c7be0fa
$collection->random() docblock
adamkiss Apr 11, 2022
574fb4a
Update src/Toolkit/A.php
adamkiss Apr 12, 2022
70b1e30
Update src/Toolkit/Collection.php
adamkiss Apr 12, 2022
b3861b0
Update tests/Toolkit/ATest.php
adamkiss Apr 14, 2022
54966aa
Update handling the Obj->get for multiple properties
adamkiss Apr 15, 2022
378a142
Apply suggestions from code review
adamkiss Apr 16, 2022
0e3008e
Default to empty array for fallback
lukasbestle Apr 17, 2022
cd083d0
Merge pull request #4270 from adamkiss/feature/array-collection-random
bastianallgeier Apr 20, 2022
5b58283
Fiber requests to non-origin urls don’t work. This fix will redirect …
bastianallgeier Apr 20, 2022
3e5fa18
Merge pull request #4280 from getkirby/fix/redirect-to-non-origins
lukasbestle Apr 23, 2022
c5296e3
Support callback to programmable user blueprints
afbora Apr 20, 2022
22974b4
Blueprint callback option support file path #4281
afbora Apr 25, 2022
22d78f8
`Uri`: Allow disabling the params parsing
lukasbestle Apr 25, 2022
7addf60
Merge pull request #4287 from getkirby/feature/2948-uri-disabled-params
bastianallgeier Apr 26, 2022
245d899
Merge pull request #4268 from adamkiss/feat-obj-get-multiple
bastianallgeier Apr 26, 2022
65bb081
Merge pull request #4281 from getkirby/fix/programmable-user-blueprints
bastianallgeier Apr 26, 2022
f97ec2a
Update dist files
bastianallgeier Apr 26, 2022
0538c04
Merge pull request #4288 from getkirby/release/3.6.6-rc.1
bastianallgeier Apr 26, 2022
0ff6757
Update dependencies
bastianallgeier May 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 68 additions & 2 deletions cacert.pem
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
## Bundle of CA Root Certificates
##
## Certificate data from Mozilla as of: Tue Mar 29 03:12:05 2022 GMT
## Certificate data from Mozilla as of: Tue Apr 26 03:12:05 2022 GMT
##
## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates
Expand All @@ -14,7 +14,7 @@
## Just configure this file as the SSLCACertificateFile.
##
## Conversion done with mk-ca-bundle.pl version 1.29.
## SHA256: d59c5c83ce7a7635fa95521d8d245677949b86d5574bfcc6f855b6a48f2d5566
## SHA256: 34a54d5191775c1bd37be6cfd3f09e831e072555dc3a2e51f4a2c4b0f8ada5cc
##


Expand Down Expand Up @@ -3279,3 +3279,69 @@ PsVq8JQdjDAKBggqhkjOPQQDAwNpADBmAjEA6ED/g94D9J+uHXqnLrmvT/aDHQ4thQEd0dlq7A/C
r8deVl5c1RxYIigL9zC2L7F8AjEA8GE8p/SgguMh1YQdc4acLa/KNJvxn7kjNuK8YAOdgLOaVsjh
4rsUecrNIdSUtUlD
-----END CERTIFICATE-----

Telia Root CA v2
================
-----BEGIN CERTIFICATE-----
MIIFdDCCA1ygAwIBAgIPAWdfJ9b+euPkrL4JWwWeMA0GCSqGSIb3DQEBCwUAMEQxCzAJBgNVBAYT
AkZJMRowGAYDVQQKDBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2
MjAeFw0xODExMjkxMTU1NTRaFw00MzExMjkxMTU1NTRaMEQxCzAJBgNVBAYTAkZJMRowGAYDVQQK
DBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2MjCCAiIwDQYJKoZI
hvcNAQEBBQ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ebqkYJpCh3DflminmtGFZhb069GHWLIzoBSSRE/yQQSwxN8PzuKlts8oB4KtItUsiRnDe+C
y748fdHif64W1lZYudogsYMVoe+KTTJvQS8TUoKU1xrBeKJR3Stwbbca+few4GeXVtt8YVMJAygC
QMez2P2ccGrGKMOF6eLtGpOg3kuYooQ+BXcBlj37tCAPnHICehIv1aO6UXivKitEZU61/Qrowc15
h2Er3oBXRb9n8ZuRXqWk7FlIEA04x7D6w0RtBPV4UBySllva9bguulvP5fBqnUsvWHMtTy3EHD70
sz+rFQ47GUGKpMFXEmZxTPpT41frYpUJnlTd0cI8Vzy9OK2YZLe4A5pTVmBds9hCG1xLEooc6+t9
xnppxyd/pPiL8uSUZodL6ZQHCRJ5irLrdATczvREWeAWysUsWNc8e89ihmpQfTU2Zqf7N+cox9jQ
raVplI/owd8k+BsHMYeB2F326CjYSlKArBPuUBQemMc=
-----END CERTIFICATE-----

D-TRUST BR Root CA 1 2020
=========================
-----BEGIN CERTIFICATE-----
MIIC2zCCAmCgAwIBAgIQfMmPK4TX3+oPyWWa00tNljAKBggqhkjOPQQDAzBIMQswCQYDVQQGEwJE
RTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRSVVNUIEJSIFJvb3QgQ0EgMSAy
MDIwMB4XDTIwMDIxMTA5NDUwMFoXDTM1MDIxMTA5NDQ1OVowSDELMAkGA1UEBhMCREUxFTATBgNV
BAoTDEQtVHJ1c3QgR21iSDEiMCAGA1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDEgMjAyMDB2MBAG
ByqGSM49AgEGBSuBBAAiA2IABMbLxyjR+4T1mu9CFCDhQ2tuda38KwOE1HaTJddZO0Flax7mNCq7
dPYSzuht56vkPE4/RAiLzRZxy7+SmfSk1zxQVFKQhYN4lGdnoxwJGT11NIXe7WB9xwy0QVK5buXu
QqOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFHOREKv/VbNafAkl1bK6CKBrqx9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EAwIBBjCBxgYDVR0fBIG+MIG7MD6gPKA6hjhodHRwOi8vY3JsLmQtdHJ1c3Qu
bmV0L2NybC9kLXRydXN0X2V2X3Jvb3RfY2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVj
dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwRVYlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxP
PUQtVHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjOPQQD
AwNpADBmAjEAyjzGKnXCXnViOTYAYFqLwZOZzNnbQTs7h5kXO9XMT8oi96CAy/m0sRtW9XLS/BnR
AjEAkfcwkz8QRitxpNA7RJvAKQIFskF3UfN5Wp6OFKBOQtJbgfM0agPnIjhQW+0ZT0MW
-----END CERTIFICATE-----
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "The Kirby 3 core",
"license": "proprietary",
"type": "kirby-cms",
"version": "3.6.5",
"version": "3.6.6",
"keywords": [
"kirby",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions config/areas/site/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
'page.changeSort' => [
'pattern' => 'pages/(:any)/changeSort',
'load' => function (string $id) {
$page = Find::page($id);
$position = null;
$page = Find::page($id);

if ($page->blueprint()->num() !== 'default') {
throw new PermissionException([
Expand Down
2 changes: 1 addition & 1 deletion panel/dist/js/index.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions panel/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions panel/src/fiber/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ export default class Fiber {

try {
const url = this.url(path, options.query);

// don't even try to request a cross-origin url
// redirect instead.
if (new URL(url).origin !== location.origin) {
this.redirect(url);
return false;
}

const response = await this.fetch(url, {
method: options.method,
body: this.body(options.body),
Expand Down
7 changes: 5 additions & 2 deletions src/Cms/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,16 @@ public static function find(string $name): array
$file = $kirby->extension('blueprints', $name);
}

// callback option can be return array or blueprint file path
if (is_callable($file) === true) {
$file = $file($kirby);
}

// now ensure that we always return the data array
if (is_string($file) === true && F::exists($file) === true) {
return static::$loaded[$name] = Data::read($file);
} elseif (is_array($file) === true) {
return static::$loaded[$name] = $file;
} elseif (is_callable($file) === true) {
return static::$loaded[$name] = $file($kirby);
}

// neither a valid file nor array data
Expand Down
8 changes: 7 additions & 1 deletion src/Cms/Roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,20 @@ public static function factory(array $roles, array $inject = [])
*/
public static function load(string $root = null, array $inject = [])
{
$kirby = App::instance();
$roles = new static();

// load roles from plugins
foreach (App::instance()->extensions('blueprints') as $blueprintName => $blueprint) {
foreach ($kirby->extensions('blueprints') as $blueprintName => $blueprint) {
if (substr($blueprintName, 0, 6) !== 'users/') {
continue;
}

// callback option can be return array or blueprint file path
if (is_callable($blueprint) === true) {
$blueprint = $blueprint($kirby);
}

if (is_array($blueprint) === true) {
$role = Role::factory($blueprint, $inject);
} else {
Expand Down
44 changes: 38 additions & 6 deletions src/Http/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function __clone()
* Creates a new URI object
*
* @param array|string $props
* @param array $inject
* @param array $inject Additional props to inject if a URL string is passed
*/
public function __construct($props = [], array $inject = [])
{
Expand All @@ -144,10 +144,7 @@ public function __construct($props = [], array $inject = [])

// parse the path and extract params
if (empty($props['path']) === false) {
$extract = Params::extract($props['path']);
$props['params'] ??= $extract['params'];
$props['path'] = $extract['path'];
$props['slash'] ??= $extract['slash'];
$props = static::parsePath($props);
}

$this->setProperties($this->props = $props);
Expand Down Expand Up @@ -372,11 +369,17 @@ public function setHost(string $host = null)
}

/**
* @param \Kirby\Http\Params|string|array|null $params
* @param \Kirby\Http\Params|string|array|false|null $params
* @return $this
*/
public function setParams($params = null)
{
// ensure that the special constructor value of `false`
// is never passed through as it's not supported by `Params`
if ($params === false) {
$params = [];
}

$this->params = is_a($params, 'Kirby\Http\Params') === true ? $params : new Params($params);
return $this;
}
Expand Down Expand Up @@ -539,4 +542,33 @@ public function unIdn()
}
return $this;
}

/**
* Parses the path inside the props and extracts
* the params unless disabled
*
* @param array $props
* @return array Modified props array
*/
protected static function parsePath(array $props): array
{
// extract params, the rest is the path;
// only do this if not explicitly disabled (set to `false`)
if (isset($props['params']) === false || $props['params'] !== false) {
$extract = Params::extract($props['path']);
$props['params'] ??= $extract['params'];
$props['path'] = $extract['path'];
$props['slash'] ??= $extract['slash'];

return $props;
}

// use the full path;
// automatically detect the trailing slash from it if possible
if (is_string($props['path']) === true) {
$props['slash'] = substr($props['path'], -1, 1) === '/';
}

return $props;
}
}
23 changes: 23 additions & 0 deletions src/Toolkit/A.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,29 @@ public static function last(array $array)
return array_pop($array);
}

/**
* Returns a number of random elements from an array,
* either in original or shuffled order
*
* @param array $array
* @param int $count
* @param bool $shuffle
* @return array
*/
public static function random(array $array, int $count = 1, bool $shuffle = false): array
{
if ($shuffle) {
return array_slice(self::shuffle($array), 0, $count);
}

if ($count === 1) {
$key = array_rand($array);
return [$key => $array[$key]];
}

return self::get($array, array_rand($array, $count));
}

/**
* Fills an array up with additional elements to certain amount.
*
Expand Down
19 changes: 19 additions & 0 deletions src/Toolkit/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,25 @@ public function query(array $arguments = [])
return $result;
}

/**
* Returns a new collection consisting of random elements,
* from the original collection, shuffled or ordered
*
* @param int $count
* @param bool $shuffle
* @return static
*/
public function random(int $count = 1, bool $shuffle = false)
{
if ($shuffle) {
return $this->shuffle()->slice(0, $count);
}

$collection = clone $this;
$collection->data = A::random($collection->data, $count);
return $collection;
}

/**
* Removes an element from the array by key
*
Expand Down
26 changes: 22 additions & 4 deletions src/Toolkit/Obj.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Kirby\Toolkit;

use Kirby\Exception\InvalidArgumentException;
use stdClass;

/**
Expand Down Expand Up @@ -62,14 +63,31 @@ public function __get(string $property)
}

/**
* Property Getter
* Gets one or multiple properties of the object
*
* @param string $property
* @param mixed $fallback
* @param string|array $property
* @param mixed $fallback If multiple properties are requested:
* Associative array of fallback values per key
* @return mixed
*/
public function get(string $property, $fallback = null)
public function get($property, $fallback = null)
{
if (is_array($property)) {
if ($fallback === null) {
$fallback = [];
}

if (!is_array($fallback)) {
throw new InvalidArgumentException('The fallback value must be an array when getting multiple properties');
}

$result = [];
foreach ($property as $key) {
$result[$key] = $this->$key ?? $fallback[$key] ?? null;
}
return $result;
}

return $this->$property ?? $fallback;
}

Expand Down