[RFC] Error, Success & Confirm Class

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

[RFC] Error, Success & Confirm Class

Post by MichaelC »

Olympus Situation:
We use the trigger_error for everything from Posting Success Messages to Errors with adding custom BBcodes.

We also have general errors and debug errors. General Errors are used for DB, template, cache and module problems. Debug errors are used for undefined variables and more.

General Errors are recorded in the Error Log.

Ascreaus Situation:
We now use modal windows for some actions (like marking topics read) but otherwise it is the same as in olympus.

Problems:
1) trigger_error() is over used and abused
2) Flash messages are nicer for a user than whole pages and modal boxes.
3) Logging is not optional, and there isn't an option to log debug errors.
4) There are no notification settings

Suggested Solution - Backend functions to produce errors/confirmation boxes/success messages:
A new error class with the following public functions:
  • flash($message, $dismiss_method, $type, $redirect = null)
    This will produce a little flash message. It will display the message. The dismiss method details whether it will fade after a certain amount of time, or whether it will stay there until dismissed. The type is failed/success and will then show a tick or cross. The redirect will be the page it should be shown on. If no option is given then it will show it on the current page. The flash message will be something like http://www.erichynds.com/examples/jquery-notify/
  • confirm($message, $modal, $yes, $no)
    This will either produce a flash message or a modal box (decided with true or false for $modal) with a yes/no confirmation option. $yes and $no will decide where to send them should they select those options.
  • debug($message)
    This will produce the debug error as we have them now, except there will be functionality to notify people about them or log them.
  • general($message)
    This will produce a general error as we have them now, except there will be functionality to notify people about them or log them.
  • info_page($message)
    Will produce an information page, the current usage in Olympus when using trigger_error().
  • modal($message)
    This will produce a modal box, as the current ascreaus behaviour is for marking forums read.
Suggested Solution - Admin Options:
There will then be the admin options for the following:
Checkbox for what would you like to log (by default GE is selected):
General Errors and Debug Errors
Checkbox for what would you like to notify you about (by default neither selected):
General Errors and Debug Errors
Method of Notifying (Checkbox):
PM, Email or Jabber.
Then for whichever is selected it will ask for the User ID's of Users to PM or emails to email or Jabber Addresses to Jabber.

As such this means:
  • Easier to produce errors
  • No information pages unless really needed.
  • Everything is easily accessible.
  • No more abusing trigger_error() - This will continue to be supported for BC like request_var(). It will just run info_page().
  • Logging is now completely optional and more flexible
  • You can log debug errors
  • You can choose to be notified of events.
Ticket: http://tracker.phpbb.com/browse/PHPBB3-11058
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

Senky Online
Extension Customisations
Extension Customisations
Posts: 314
Joined: Thu Jul 16, 2009 4:41 pm

Re: [RFC] Error, Success & Confirm Class

Post by Senky »

+1, absolutelly!
Unknown Bliss wrote:
  • flash($message, $dismiss_method, $type, $redirect = null)
    This will produce a little flash message. It will display the message. The dismiss method details whether it will fade after a certain amount of time, or whether it will stay there until dismissed. The type is failed/success and will then show a tick or cross. The redirect will be the page it should be shown on. If no option is given then it will show it on the current page. The flash message will be something like http://www.erichynds.com/examples/jquery-notify/
The best idea I have seen for a long time! This would remove all those abusing trigger_error calls when only one information and one link is provided, and will replace it with one flash, while the rest of the page remains. Totally perfect!

User avatar
Erik Frèrejean
Registered User
Posts: 207
Joined: Thu Oct 25, 2007 2:25 pm
Location: surfnet
Contact:

Re: [RFC] Error, Success & Confirm Class

Post by Erik Frèrejean »

Unknown Bliss wrote:We also have general errors and debug errors. General Errors are used for DB, template, cache and module problems. Debug errors are used for undefined variables and more.
phpBB doesn't actually has debug errors of itself as E_USER_NOTICE are mapped to a fatal error as well.
Available on .com
Support Toolkit developer

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] Error, Success & Confirm Class

Post by Oleg »

trigger error is also used for error handling therefore you might have to deal with that somehow. Sensible error handling in php is somewhere between insanely annoying and impossible in my opinion but I would support attempting to make our implementation of it less of a disaster.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC] Error, Success & Confirm Class

Post by MichaelC »

trigger_error() would become a shortcut for a general error.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.


Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] Error, Success & Confirm Class

Post by Oleg »

Replacing trigger_error with a collection of functions for different levels of errors/non-errors seems reasonable.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] Error, Success & Confirm Class

Post by imkingdavid »

Oleg wrote:Replacing trigger_error with a collection of functions for different levels of errors/non-errors seems reasonable.
Agreed. As long as it is done properly. There should also be plenty of documentation with examples of what each level of error method to use in different cases.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
psoTFX
Registered User
Posts: 1984
Joined: Tue Jul 03, 2001 8:50 pm
Contact:

Re: [RFC] Error, Success & Confirm Class

Post by psoTFX »

+1 - we got lazy with trigger_error in 2.x and it ultimately subsumed all the messaging roles, wasn't intended and shouldn't have happened. Oh, call it growl not flash :P

mvader
Registered User
Posts: 6
Joined: Tue Jul 10, 2012 12:48 am
Contact:

Re: [RFC] Error, Success & Confirm Class

Post by mvader »

I think it's quite a good idea!

Post Reply