Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Notify messages can get repeated multiple times on single pages

For example Installer will echo several times in some areas and and Warning Admin password not set is also repeated in Forums.
Made a commit regarding this issue https://github.com/php-fusion/PHP-Fusion/commit/f35d68cdae51ce5c73b19dc0f6319534ab30178f can you please make sure it works as expected in areas like Forum, I'm unable to test ATM.
Yes it is not repeated now, however we do get the message below the upper center panels.
Oh, yea.... Didn't tested with upper panels, it's because they are echoed after.
https://github.com/php-fusion/PHP-Fusion/blob/9.00/themes/Septenary/includes/content.php#L30-34 Will change it later.

Quote

Made a commit regarding this issue
- by JoiNNN

It is better to solve in addNotice(). I improved that: https://github.com/php-fusion/PHP-Fus...33282f899e

Test:
CodeDownload  
addNotice("info", array(1, 2));
addNotice("info", array(1, 2));
addNotice("info", "info1");
addNotice("info", "info1");
addNotice("info", "info1");

var_dump(getNotices());

Good addition, I avoided doing any kind of checking/searching of similar notices as I was concerned with performance, but I guess there won't be many notices anyway at any given time so the performance hit is rather unnoticeable. Another reasoning for it was that if you get the same notice added more than once that is a sign there is something wrong in your code flow and you should fix it right away. What I'm saying is that if everything is coded properly and notices are issued and rendered when they are supposed to there won't be duplicates.
While in debug mode (hmm... we need a system wide debug mode which could be enabled in Admin Panel and would output all kind of useful information for developers) can we get like a custom E_NOTICE in Error log when a duplicate is attempted?

Quote

Good addition, I avoided doing any kind of checking/searching of similar notices as I was concerned with performance,
- by JoiNNN

If you want to achieve better performance, use the message as a key and not as a value. That way the code will be twice as fast. Even faster than the original solution without any search.

Quote


but I guess there won't be many notices anyway at any given time so the performance hit is rather unnoticeable.
- by JoiNNN

Yes, each solution executed thousand times takes less than two hundredth of a second, so it does not matter so much compared with other issues.

Quote

Another reasoning for it was that if you get the same notice added more than once that is a sign there is something wrong in your code flow and you should fix it right away.
- by JoiNNN

You may be right. However, I remember a case when a message was repeated because of an AJAX solution when a code had been executed more times before notices was rendered. I thought it could happen in other cases too. Well, you made me uncertain.

Quote

can we get like a custom E_NOTICE in Error log when a duplicate is attempted?
- by JoiNNN

Yes, we can but I think we should do it only in debug mode.
You are right about AJAX, however the reason I'm not concerned about it right now is that we don't have any standard yet for AJAX code, server or client side, although we do use it in a few places. Part of the standard would be that when you write code for such calls the response will always be json encoded and contain all the notices which would be then injected in dom.
I've been plotting writing a standard primarily for forms, where we would be able to send the data with AJAX then receive all errors and notices and after inject them so it looks just as it does now after you submit a form. Just as important, we need this for when we submit a form in Admin Panel, where we would do an AJAX call and check if the user is still logged in and if not dropdown a modal login form.
I'm offtopic, too many ideas... too lazy to write them in code :D

Quote

Oh, yea.... Didn't tested with upper panels, it's because they are echoed after.


Thank you, I fixed it now!
Thread Information
Author
Replies
9 posts
Views
1,058 times
Last Post
Last updated on 4 years ago
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.