Add error message if newsbox couldn't be found?

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Add error message if newsbox couldn't be found?

Post by cmb » Mon Jul 07, 2014 3:24 pm

Hello Community,

from time to time there are support requests that are related to newsbox() returning nothing. So we might consider to let newsbox() return an appropriate error message if the requested newspage couldn't be found.

However, that might cause existing installations to display these messages, and the user might not be able to fix it for himself.

Another idea is to trigger a PHP notice/warning, when the page doesn't exists, what would be helpful only if the debug mode is enabled.

So I'm not sure, if and how we should improve this issue.

Any ideas?

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Add error message if newsbox couldn't be found?

Post by Tata » Mon Jul 07, 2014 4:58 pm

1. For me - as the visitor - it is non of my business, if there is some hidden page to be show in a newsbox. If this for whichever reason doesn't work, I simply don't see it.
2. For me - as the webmaster - it is importnant to see if such page exist, if it is properly defined in a plugin call etc.

So my suggestioin would be to check after login:
If a newsbox is used,
If the call syntax is OK - this could be included in all plugins maybe
if a page used in the call exist.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Add error message if newsbox couldn't be found?

Post by cmb » Mon Jul 07, 2014 5:35 pm

Tata wrote:1. For me - as the visitor - it is non of my business, if there is some hidden page to be show in a newsbox. If this for whichever reason doesn't work, I simply don't see it.
2. For me - as the webmaster - it is importnant to see if such page exist, if it is properly defined in a plugin call etc.
Good point!
Tata wrote:If a newsbox is used,
If the call syntax is OK - this could be included in all plugins maybe
That is a good idea, but it cannot easily be accomplished. Basically, it would be necessary to parse the template for plugin calls and to check their parameters. The latter would require PHP's Reflection API (which is available since PHP 5 only), and even this might not be sufficient (most likely the parameter types can't be verified). However, that is only the tip of the iceberg. What about templates that are dynamically switched? What if there are plugin calls conditionally defined, e.g.

Code: Select all

<?php if (XH_ADM) {echo plugin();}?>
In the end we won't need a static analysis tool, that would likely be more complex than CMSimple.

If we'd care only for correct syntax, checking the template shouldn't be much of a problem. Holger has already implemented such a syntax check in http://www.cmsimpleforum.com/viewtopic.php?f=16&t=7730, and I just found php_check_syntax() (available since PHP 5.0.4), which should make that even easier.[1]
Tata wrote:if a page used in the call exist.
This, on the other hand, is already checked in function newsbox(). I suggest that we emit a respective warning, when the user is logged in (i.e. if (XH_ADM)); otherwise we stick to the current behavior (i.e. silently return nothing).

PS: [1] I was too quick. The function is available from PHP 5.0.0 to 5.0.4 only, so it is not useful.
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Add error message if newsbox couldn't be found?

Post by Tata » Mon Jul 07, 2014 5:44 pm

cmb wrote:
Tata wrote:If a newsbox is used,
If the call syntax is OK - this could be included in all plugins maybe
Of course, this was only an idea, it is really no crucial need.
cmb wrote:This, on the other hand, is already checked in function newsbox(). I suggest that we emit a respective warning, when the user is logged in (i.e. if (XH_ADM)); otherwise we stick to the current behavior (i.e. silently return nothing).
Well, here I would preferre the warning in the backend after login:
1. The page defined in newsboxcall was not found.
2. There is an error while loading the page XY in newsbox, please check the path and/syntax.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Add error message if newsbox couldn't be found?

Post by cmb » Mon Jul 07, 2014 6:09 pm

Tata wrote:Well, here I would preferre the warning in the backend after login:
1. The page defined in newsboxcall was not found.
2. There is an error while loading the page XY in newsbox, please check the path and/syntax.
I would prefer that too, but it would require the static analysis I've mentioned above.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply