Jump to content

Server 500 error. No PHP error?


suntrop
 Share

Recommended Posts

Sometimes I see a server error 500, instead of a PHP/PW error message. I don't know why and it makes it hard to figure out what is wrong.

Here is an example from today. 

try {
	$return = wireRenderFile('partials/confirm', $vars);
} catch (\Exception $e) {
	throw new WireException('Render Partial failed: ' . $e->getMessage());
}

Error: I was using an old/missing function in the file partial/confirm.php. But why do I see a server error (500) and not a PHP error message or the exception? Is this something particular to my server config?

Link to comment
Share on other sites

It took some time, but I figured out here is something wrong with my TracyDebugger installation. When I remove the folder I see the PW exception. I just noticed I can’t save anything in the TD config. I get redirected to a Bookmark page in PW. I can’t uninstall it or disable it, same error. I‘ll try to figure out if there is any of my plugins causing the trouble. 

Link to comment
Share on other sites

I have (updated to) v4.13.6 on PW 3.0.98 with PHP 7.0.11. I disabled all my modules and still got the server error.

Whenever I click the Save button I get redirected to /processwire/module/bookmarks/ nothing will be saved and the error message "ProcessWire: Unrecognized path" is displayed. TD is enabled and Output mode is set to Detect.

Link to comment
Share on other sites

And everything works as expected when Tracy is uninstalled? Can you save config settings for other modules?

Any chance you could try an older version of Tracy - I wonder if I recently did something that makes it require a new version of PW?

Link to comment
Share on other sites

Reason found. It is one of my modules ?… I don't know why it didn't work when I disabled all modules.

// Add hook for Email fields, to prevent two email fields share the same email address
$this->addHookAfter("InputfieldEmail::processInput", $this, "validEmail");

protected function validEmail($event){

		if ($event->wire('page')->rootParent->id != 2) return;

		$field = $event->object;

		if ($field->name == 'email') {
			$page = $this->modules->ProcessPageEdit->getPage();

			$oldEmail = $page->get($field->name); 
			$newEmail = $field->value;

			$existEmail = $this->wire('users')->get('id!=' . $page->id . ', email=' . $newEmail);
			if($existEmail && $existEmail->id > 0) {
				$field->value = $oldEmail;
				$field->error($this->_("Die E-Mail-Adresse $newEmail ist bereits für einen Kunden gespeichert"));
			}

		}
	}

I had some trouble before, with this one (don't remember what exactly). I need this, to prevent users share the same email address.

But the server error stays the same. Even without the code above, and I can save TD settings, I still get the error 500 if TB is enabled. 

Edited by suntrop
Link to comment
Share on other sites

Tracy's settings contain an InputfieldEmail field so I expect that is where the conflict is. You need to add a condition to your hook to make sure it's only affecting ProcessPageEdit rather than ProcessModule and others. Sorry, gotta run so now time for an example, but hopefully that will get you going.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...