suntrop Posted October 23, 2018 Posted October 23, 2018 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?
nbcommunication Posted October 26, 2018 Posted October 26, 2018 Hi suntrop, My best guess is that the error is occurring before PW has determined that you are logged in. I'm pretty sure the PW error message is only displayed to logged in users - that's my experience anyway! Cheers, Chris NB
adrian Posted October 26, 2018 Posted October 26, 2018 Do you have PW's debug mode on? If not it suppresses PHP errors. Alternatively, TracyDebugger will in most cases display these errors even with debug mode off. 1
suntrop Posted October 26, 2018 Author Posted October 26, 2018 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.
adrian Posted October 26, 2018 Posted October 26, 2018 1 minute ago, suntrop said: It took some time, but I figured out here is something wrong with my TracyDebugger installation Sorry for the trouble - what version of Tracy, PHP, and PW are you running?
suntrop Posted October 26, 2018 Author Posted October 26, 2018 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.
adrian Posted October 26, 2018 Posted October 26, 2018 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?
suntrop Posted October 26, 2018 Author Posted October 26, 2018 (edited) 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 October 26, 2018 by suntrop
adrian Posted October 26, 2018 Posted October 26, 2018 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now