Skip to content

Commit fcc513f

Browse files
committed
Make the updateCategoriesStructure method more secure
1 parent 0eb470c commit fcc513f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

index.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@
5555
],
5656
'pageMethods' => [
5757
'updateCategoriesStructure' => function($fieldname) {
58-
$newFieldContent = $this->$fieldname()->yaml()[0];
59-
foreach(kirby()->languages() as $l) {
60-
$this->save([$fieldname => $newFieldContent], $l->code());
58+
$fieldContent = $this->$fieldname()->yaml();
59+
if(count($fieldContent) == 2 && is_int($fieldContent[1])) {
60+
$newFieldContent = $fieldContent[0];
61+
foreach(kirby()->languages() as $l) {
62+
$this->save([$fieldname => $newFieldContent], $l->code());
63+
}
6164
}
6265
},
6366
],

0 commit comments

Comments
 (0)