mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
fix: jury-fieldset.php calling old() with wrong signature for partage
jury-fieldset.php called old('jury_promoteur') as a global function,
but the partage context defines old(array $data, string $key) —
passing a string where array is expected caused a TypeError.
Changed jury-fieldset.php to use $oldFn callable (like fieldset-tfe-info.php),
with fallback to global old() when not provided. The add-mode repopulation
block no longer calls the global old() directly.
This commit is contained in:
@@ -12,8 +12,11 @@
|
||||
* $juryPresident string|null (Deprecated — no longer displayed)
|
||||
* $showPromoteurUlb bool Show ULB promoteur field (default: true)
|
||||
* $promoteurUlbConditional bool If true, field is hidden unless finality=Approfondi
|
||||
* callable|null $oldFn — callable($key, $default='') to retrieve old/current values;
|
||||
* falls back to the global old() function when null.
|
||||
* array $formData — raw form data array (used for jury repopulation).
|
||||
*
|
||||
* In add-mode repopulation: if old() exists and values are null, populate from it.
|
||||
* In add-mode repopulation: if $oldFn is provided and values are null, populate from it.
|
||||
*/
|
||||
|
||||
$juryPromoteur = $juryPromoteur ?? null;
|
||||
@@ -25,12 +28,13 @@ $lecteursExternes = $lecteursExternes ?? [];
|
||||
$showPromoteurUlb = $showPromoteurUlb ?? true;
|
||||
$promoteurUlbConditional = $promoteurUlbConditional ?? false;
|
||||
$adminMode = $adminMode ?? false;
|
||||
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
|
||||
|
||||
// Add-mode repopulation from flash data
|
||||
$addMode = ($juryPromoteur === null && empty($juryPromoteurs) && $juryPromoteurUlb === null && empty($juryPromoteursUlb) && empty($lecteursInternes) && empty($lecteursExternes));
|
||||
if ($addMode && function_exists('old')) {
|
||||
if ($addMode) {
|
||||
// jury_promoteur may be array (new form) or scalar (legacy)
|
||||
$promoteursOld = old('jury_promoteur');
|
||||
$promoteursOld = $oldFn('jury_promoteur');
|
||||
if (is_array($promoteursOld)) {
|
||||
foreach ($promoteursOld as $name) {
|
||||
$name = trim($name ?? '');
|
||||
@@ -40,7 +44,7 @@ if ($addMode && function_exists('old')) {
|
||||
$juryPromoteur = $promoteursOld;
|
||||
}
|
||||
// jury_promoteur_ulb_name may be array (new form) or scalar (legacy)
|
||||
$promoteursUlbOld = old('jury_promoteur_ulb_name');
|
||||
$promoteursUlbOld = $oldFn('jury_promoteur_ulb_name');
|
||||
if (is_array($promoteursUlbOld)) {
|
||||
foreach ($promoteursUlbOld as $name) {
|
||||
$name = trim($name ?? '');
|
||||
@@ -50,11 +54,11 @@ if ($addMode && function_exists('old')) {
|
||||
$juryPromoteurUlb = $promoteursUlbOld;
|
||||
}
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$n = old("jury_lecteur_interne:$i");
|
||||
$n = $oldFn("jury_lecteur_interne:$i");
|
||||
if (is_string($n) && $n !== '') $lecteursInternes[] = ['name' => $n];
|
||||
}
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$n = old("jury_lecteur_externe:$i");
|
||||
$n = $oldFn("jury_lecteur_externe:$i");
|
||||
if (is_string($n) && $n !== '') $lecteursExternes[] = ['name' => $n];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user