Forms - Internal Server Error

Hi. I recently installed the NC Forms app. I designed a form but when I try access the form at its URL from outside NC I get an ‘Internal Server Error’ message.

I am running NC 18.0.2.2 and latest version of Forms app 1.1.1

Any help appreciated.
Brian

Open the Nextcloud log file and search for any error which appears when you try to use the app.

I have the same problem. It only happens when I am not logged in. Otherwise it appears fine. However, this makes it impossible to send surveys to other people.

My log:

Exception: Argument 2 passed to OCA\Forms\Db\NotificationMapper::findByUserAndForm() must be of the type string, null given, called in apps/forms/lib/Controller/PageController.php on line 277

Disable the form from the terminal:

php occ app:disable forms

why would I disable the form?

Because that makes the problem

Hi. Same problem in the same context and with same logs.
Disabling the app is not a solution…

In theory : https://github.com/nextcloud/forms/issues/178 :thinking:

Indeed the attached patch (PageController_notifMapper_patch.txt) works fine!

1 Like

Hi,

can you tell me, wehre i have to place this patch?

1 Like

Hi,

As you can see in the txt file, it is a git diff of the concerned file. Under your Nextcloud directory, you will find the following file:

/apps/forms/lib/Controller/PageController.php

On line ~278 you might find, inside a try…catch, the following code:

 $notification = $this->notificationMapper->findByUserAndForm($form->getId(), $this->userId);

Then replace this line by:

if($this->userId === null) {
    $notification = $this->notificationMapper->findByUserAndForm($form->getId(), '');
} else {
    $notification = $this->notificationMapper->findByUserAndForm($form->getId(), $this->userId);
}

This should work fine :slight_smile:

1 Like

Hello again,

thanks for help and sorry for my lousy english.

if i deactivate this one line 278 then it works on Firefox very well.

On IE it shows just the Headline of my Cloud and in Edge it does not even open the app in the Cloud.

If I replace the Code then it Shows in all Browsers just an error. And it doesn´t matters if im signed in or not.

Here is the Code how I changed it.

Am I to stupid?

		$participants = $this->voteMapper->findParticipantsByForm($form->getId());		

	try {
		if($this->userId === null) {
			$notification = $this->notificationMapper->findByUserAndForm($form->getId(), '');
		} else {
			$notification = $this->notificationMapper->findByUserAndForm($form->getId(), $this->userId);
		}

	} catch (DoesNotExistException $e) {
		$notification = null;
	}

Hello,

What do you mean precisely?

About the error in all browsers… it may be a copy/paste issue (by inserting a hidden character like a no-break space or something like that). Is the code you pasted exactly the code copied from your /apps/forms/lib/Controller/PageController.php file?

Hello,

here is a part off the Code. It start on line 256 and ends in line 282.
I just deaktivatet the Line 277 with a “#”.

256	public function gotoForm($hash) {
		try {
			$form = $this->eventMapper->findByHash($hash);
		} catch (DoesNotExistException $e) {
			return new TemplateResponse('forms', 'no.acc.tmpl', []);
		}

		if ($form->getExpire() === null) {
			$expired = false;
		} else {
			$expired = time() > strtotime($form->getExpire());
		}

		if ($expired) {
			return new TemplateResponse('forms', 'expired.tmpl');
		}

		$votes = $this->voteMapper->findByForm($form->getId());
		$participants = $this->voteMapper->findParticipantsByForm($form->getId());		

		try {
#			$notification = $this->notificationMapper->findByUserAndForm($form->getId(), $this->userId);
		} catch (DoesNotExistException $e) {
			$notification = null;
		}

282		if ($this->hasUserAccess($form)) {

With this adjustment it works in Firefox and Edge. In IE it shows just my headline from Nextcloud. It works also on Andoid browsers (Firefox and Edge). I just tryed it with this browsers.


Here is a link, iff you want to check yourself how a form looks like.
https://cloud.hmosel.info/index.php/apps/forms/form/XEo6NHuCuFNniFMA


Iff i replace the Line 277

# $notification = $this->notificationMapper->findByUserAndForm($form->getId(),

to the Code

if($this->userId === null) {
    $notification = $this->notificationMapper->findByUserAndForm($form->getId(), '');
} else {
    $notification = $this->notificationMapper->findByUserAndForm($form->getId(), $this->userId);
}

then i just get an error message from server. In all browsers.
Iff you want i can do this and then you can read the Error message yourself.


The Code is stored in

..... nextcloud/apps/forms/lib/Controller/PageController.php


Thanks for your patience with me.

Greetings from Hamburg

1 Like