Small bug in plugin MessageBox

Hi guys,

As I was writing the prependArray function for my previous email regarding the feature request, I noticed a bug in the MessageBox plugin.
If you look at the appendArray method:

var currentMessage = ""; var newMessage = "";

// Do we have a message?
if( isEmpty() ){
// Set default message
setMessage(type=‘information’,messageArray=arguments.messageArray);
}
else{
// Get Current Message
currentMessage = getMessage();
// Append
ArrayPrePend(arguments.messageArray,currentMessage.message);
// Set it back
setMessage(type=currentMessage.type,messageArray=arguments.messageArray);
}

You will see that when there is no message, the message type is set to ‘information’ but the setMessage method will only accept ‘error’, ‘warning’, or ‘info’ as possible values:

// check message type
if( refindnocase("(error|warning|info)", trim(arguments.type)) ){

} else {
$throw(“The message type is invalid: #arguments.type#”,“Valid types are info,error or warning”,“MessageBox.InvalidMessageType”);
}

Also note here again that for the appendArray method, the ArrayPrePend function is used with the arguments in reversed order… Suggest for readability to use ArrayAppend instead with the arguments in the correct order.

Cheers!

Hi Guys,

The same is true for methods:

info() and append().

Cheers,
Tom

Hi Guys,

I have altered the MessageBox plugin and created a custom plugin as an extension of the core plugin.

It is attached to this email, I thought it would be nice for Luis to use as a guide when updating the core plugin.
(I also added my feature request)

Cheers,
Tom

MessageBox.cfc (6.17 KB)

Hi Guys,

I created a bug myself in the previous file…
I see now why ArrayPrePend was used in the appendArray :). It expects a string as the second argument.

Updated the MessageBox plugin as per attached.

Cheers,
Tom

MessageBox.cfc (6.17 KB)

Tom this is great, is there a way to send me this via as a pull request from git?

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Hi Luis,

I sure can. Is there any procedure I need to follow?

Cheers,
Tom Van Schoor

Yes

Get a github account
Fork coldbox
Then setup a local dev for coldbox usin your fork
Make sure you work on the development branch
Do your changes
Commit and push to your repo
Via github do a send pull request
That’s it