fix: replace toPages() with direct UUID resolution in CSV export
All checks were successful
Deploy Production / Deploy to Production (push) Successful in 40s
All checks were successful
Deploy Production / Deploy to Production (push) Successful in 40s
site()->find(false, false, ...uuids) passed booleans to a typed variadic
parameter, which can throw on PHP 8.1+. Resolve each UUID individually via
kirby()->page($uuid) and add null guard for page('livres-blancs').
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5d2e78367e
commit
5ae8dd0d17
1 changed files with 17 additions and 3 deletions
|
|
@ -15,7 +15,13 @@ Kirby::plugin('world-game/csv-export', [
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entries = page('livres-blancs')->contactDatabase()->toStructure();
|
$livresBlancs = page('livres-blancs');
|
||||||
|
if (!$livresBlancs) {
|
||||||
|
http_response_code(500);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$entries = $livresBlancs->contactDatabase()->toStructure();
|
||||||
|
|
||||||
header('Content-Type: text/csv; charset=UTF-8');
|
header('Content-Type: text/csv; charset=UTF-8');
|
||||||
header('Content-Disposition: attachment; filename="' . date('ymd') . '-contacts.csv"');
|
header('Content-Disposition: attachment; filename="' . date('ymd') . '-contacts.csv"');
|
||||||
|
|
@ -26,9 +32,17 @@ Kirby::plugin('world-game/csv-export', [
|
||||||
fputcsv($out, ['Prénom', 'Nom', 'Email', 'Entreprise', 'Fonction', 'Livres blancs', 'Date'], ';');
|
fputcsv($out, ['Prénom', 'Nom', 'Email', 'Entreprise', 'Fonction', 'Livres blancs', 'Date'], ';');
|
||||||
|
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
|
$uuids = $entry->whitePaper()->value();
|
||||||
|
if (!is_array($uuids)) {
|
||||||
|
$uuids = [];
|
||||||
|
}
|
||||||
|
|
||||||
$titles = [];
|
$titles = [];
|
||||||
foreach ($entry->whitePaper()->toPages() as $wp) {
|
foreach ($uuids as $uuid) {
|
||||||
$titles[] = $wp->title()->value();
|
$wp = kirby()->page($uuid);
|
||||||
|
if ($wp) {
|
||||||
|
$titles[] = $wp->title()->value();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fputcsv($out, [
|
fputcsv($out, [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue