Skip to content

Commit

Permalink
Merge pull request #16 from oveleon/develop
Browse files Browse the repository at this point in the history
[Bugfix] Fix potential PHP 8.1 errors
  • Loading branch information
zoglo authored Oct 27, 2022
2 parents f60844c + 755b4c1 commit 3a12e36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Resources/contao/classes/AdvancedForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function compileFormFields($arrFields, $formId, Form $form)
return $manager->getFieldsWithoutPageBreaks();
}

if ($_POST['pageSwitch'] === 'back')
if (isset($_POST['pageSwitch']) && $_POST['pageSwitch'] === 'back')
{
$manager->storeData($_POST, [], (array) $_SESSION['FILES']);
$this->redirectToStep($manager, $manager->getPreviousStep());
Expand Down
17 changes: 15 additions & 2 deletions src/Resources/contao/classes/FormPageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ public function storeData(array $submitted, array $labels, array $files)
*/
public function getDataOfStep($step)
{
if (!isset($_SESSION['FORMSTORAGE'][$this->objForm->id][$step]))
{
return [];
}

return (array) $_SESSION['FORMSTORAGE'][$this->objForm->id][$step];
}

Expand Down Expand Up @@ -501,6 +506,11 @@ public function setPreviousStepsWereInvalid()
*/
public function getPreviousStepsWereInvalid()
{
if (!isset($_SESSION['FORMSTORAGE_PSWI'][$this->objForm->id]))
{
return false;
}

return $_SESSION['FORMSTORAGE_PSWI'][$this->objForm->id] === true;
}

Expand Down Expand Up @@ -629,7 +639,7 @@ public function validateField(FormFieldModel $formField, $step)
$form = $this->createDummyForm();

// HOOK: load form field callback
if (isset($GLOBALS['TL_HOOKS']['loadFormField']) && \is_array($GLOBALS['TL_HOOKS']['loadFormField']))
if (isset($GLOBALS['TL_HOOKS']['loadFormField']) && is_array($GLOBALS['TL_HOOKS']['loadFormField']))
{
foreach ($GLOBALS['TL_HOOKS']['loadFormField'] as $callback)
{
Expand Down Expand Up @@ -703,7 +713,10 @@ public function validateField(FormFieldModel $formField, $step)
protected function createDummyForm()
{
$form = new \stdClass();
$form->form = $this->objForm->id;
$form->form = $this->objForm->id;
$form->headline = null;
$form->typePrefix = null;
$form->cssID = null;

return new Form($form);
}
Expand Down

0 comments on commit 3a12e36

Please sign in to comment.