- Affected App
- WoltLab Suite Core
Hallo zusammen,
Ich habe ein seltsames Problem in einer meiner EAs. Auf der frisch aufgesetzten Testumgebung wirft beim Bearbeiten eines Objektes das UserFormField des AbstractFormBuilderForms folgenden Fehler:
Code: Error
Error Type:
wcf\system\exception\ErrorException
Error Message:
Attempt to read property "username" on null
File:
*/lib/system/WCF.class.php (344)
Stack Trace:
#0 */lib/system/form/builder/field/user/UserFormField.class.php (234):
wcf\system\WCF::handleError(2, 'Attempt to read property "username" on null', '*/lib/system/form/builder/field/user/UserFormField.class.php', 234)
#1 */lib/system/form/builder/field/AbstractFormField.class.php (223):
wcf\system\form\builder\field\user\UserFormField->value(0)
#2 */lib/system/form/builder/FormDocument.class.php (645):
wcf\system\form\builder\field\AbstractFormField->updatedObject([ 6 items ], event\data\participant\Participant, true)
#3 */lib/form/AbstractFormBuilderForm.class.php (246):
wcf\system\form\builder\FormDocument->updatedObject(event\data\participant\Participant, true)
#4 */lib/form/AbstractFormBuilderForm.class.php (142):
wcf\form\AbstractFormBuilderForm->setFormObjectData()
#5 */lib/page/AbstractPage.class.php (339):
wcf\form\AbstractFormBuilderForm->readData()
#6 */lib/page/AbstractPage.class.php (122):
wcf\page\AbstractPage->show()
#7 */lib/system/request/Request.class.php (89):
wcf\page\AbstractPage->__run()
#8 */lib/system/request/RequestHandler.class.php (119):
wcf\system\request\Request->execute()
#9 */event/acp/index.php (8):
wcf\system\request\RequestHandler->handle('event', true)
Display More
Wie man sehen kann greift der Stacktrace ausschließlich auf WCF-Standard-Klassen zurück. Trotzdem der Vollständigkeit halber:
PHP: ParticipantAddForm
<?php
namespace event\acp\form;
use event\data\group\ParticipantGroupList;
use event\data\participant\ParticipantAction;
use wcf\form\AbstractFormBuilderForm;
use wcf\system\form\builder\container\FormContainer;
use wcf\system\form\builder\field\IsDisabledFormField;
use wcf\system\form\builder\field\TextFormField;
use wcf\system\form\builder\field\user\UserFormField;
class ParticipantAddForm extends AbstractFormBuilderForm {
/**
* @inheritDoc
*/
public $activeMenuItem = 'event.acp.menu.link.participant.add';
/**
* @inheritDoc
*/
public $formAction = 'create';
/**
* @inheritDoc
*/
public $neededPermissions = ['admin.event.canManageParticipant'];
/**
* @inheritDoc
*/
public $objectActionClass = ParticipantAction::class;
/**
* @inheritDoc
*/
protected function createForm() {
parent::createForm();
$dataContainer = FormContainer::create('generalSection')
->appendChildren([
TextFormField::create('participantName')
->label('event.acp.participant.participantName')
->description('event.acp.participant.participantName.description')
->required()
->autoFocus()
->maximumLength(255)
]);
$availabilityContainer = FormContainer::create('availabilitySection')
->label('event.acp.participant.availability')
->appendChildren([
UserFormField::create('userID')
->label('event.acp.participant.userID')
->description('event.acp.participant.userID.description'),
IsDisabledFormField::create()
->label('event.acp.participant.isDisabled')
->description('event.acp.participant.isDisabled.description')
]);
$this->form->appendChildren([
$dataContainer,
$availabilityContainer
]);
}
}
Display More
PHP: ParticipantEditForm
<?php
namespace event\acp\form;
use event\data\participant\Participant;
use event\data\participant\ParticipantCache;
use wcf\system\exception\IllegalLinkException;
use wcf\system\WCF;
class ParticipantEditForm extends ParticipantAddForm {
/**
* @inheritDoc
*/
public $formAction = 'edit';
/**
* @inheritDoc
*/
public function readParameters() {
parent::readParameters();
if (isset($_REQUEST['id'])) {
$this->formObject = new Participant($_REQUEST['id']);
if (!$this->formObject->participantID) {
throw new IllegalLinkException();
}
} else {
throw new IllegalLinkException();
}
}
}
Display More
Hat jemand eine Idee, wo der Fehler liegt?