Skip to content

Commit 9a10a45

Browse files
fix: Missing lang
1 parent 152314d commit 9a10a45

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

commands/clean/content.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
$cleanContent = function (
99
CLI $cli,
1010
Generator $collection,
11-
array|null $ignore = null,
12-
string $lang = 'default',
11+
string $lang,
12+
array $ignore = [],
1313
bool $dryrun = false,
1414
): void {
1515
foreach ($collection as $item) {
@@ -25,10 +25,10 @@
2525

2626
// get the keys and normalize to lowercase
2727
$originalContentKeys = array_keys($contentFields);
28-
$contentFieldKeys = array_map('mb_strtolower', $originalContentKeys);
28+
$contentFieldKeys = array_map('mb_strtolower', $originalContentKeys);
2929

3030
// get all field keys from blueprint and normalize to lowercase
31-
$blueprintFields = array_keys($item->blueprint()->fields());
31+
$blueprintFields = array_keys($item->blueprint()->fields());
3232
$blueprintFieldKeys = array_map('mb_strtolower', $blueprintFields);
3333

3434
// get all field keys that are in $contentFieldKeys but not in $blueprintFieldKeys
@@ -53,7 +53,7 @@
5353
}
5454

5555
// don't update models that have changes
56-
if ($item->version('changes')->exists() === true) {
56+
if ($item->version('changes')->exists($lang) === true) {
5757
$cli->error('The ' . $item::CLASS_ALIAS . ' (' . $item->id() . ') has changes and cannot be cleaned. Save the changes and try again.');
5858
}
5959

@@ -68,7 +68,7 @@
6868
// check if the version exists for the given language
6969
// and try to update the page with the data
7070
if ($version->exists($lang) === true) {
71-
$version->update($data);
71+
$version->update($data, $lang);
7272
}
7373
}
7474
};
@@ -101,9 +101,13 @@
101101
// should call kirby models for each loop
102102
// since generators cannot be cloned
103103
// otherwise run into an exception
104-
$collection = $kirby->models();
105-
106-
$cleanContent($cli, $collection, $ignore, $language->code(), $dryrun);
104+
$cleanContent(
105+
cli: $cli,
106+
collection: $kirby->models(),
107+
lang: $language->code(),
108+
ignore: $ignore,
109+
dryrun: $dryrun
110+
);
107111
}
108112

109113
$cli->success('The content files have been cleaned');

0 commit comments

Comments
 (0)