Fork me on GitHub

Error Handling in PN  Bottom

  • I would like to know what are the possible and appropriate methods for error handling within postnuke (0.8)?
    I did not find anything about that in the documentation Wiki.
  • If you mean error and status message logging, this has just been changed after the release of MS2. The underlying data structure has been changed to be array-based. In a parallel move, the API has been extended to provide functions to handle the error and status message through the LogUtil class. The entire PN codebase has been updated to reflect this change.

    The net result of this is that we can now capture and display multiple erros which also have the ability to display some more informative supporting info which will make tracking and solving such errors much easier.

    Does that answer your question?

    Greetings
    R
  • rgasch

    The underlying data structure has been changed to be array-based... The net result of this is that we can now capture and display multiple erros


    "YEAH!", cried the people... and there was much rejoicing!

    --
    Under Construction!
  • Sounds great, and how does the implementation work? What I see in the example modules at the moment looks like this:

    Code

    if ($dict->ExecuteSQLArray($sqlarray) != 2) {
            pnSessionSetVar('errormsg', _EXAMPLECREATETABLEFAILED);
            return false;
        }

    or

    Code

    if (!pnSecAuthAction(0, 'Example::', '::', ACCESS_OVERVIEW)) {
            return DataUtil::formatForDisplayHTML(_MODULENOAUTH);
        }

    How do I modify these to reflect new way to code them?



    edited by: come, Oct 15, 2006 - 09:57 PM
  • The 1st code sample you pasted above now becomes:

    Code

    if ($dict->ExecuteSQLArray($sqlarray) != 2) {
            return LogUtil::registerError (_EXAMPLECREATETABLEFAILED);
        }


    The 2nd piece of code you pasted hasn't been changed yet in the PN codebase, but it should probably also be converted to use LogUtil::registerError().

    Greetings
    R
  • Thanks. The LogUtil::registerError function doesn't seem to be integrated in .8MS2 yet. When will it be available?
  • I just noticed that the LogUtil::registerError is already implemented in the .8 nightly build, but when I exchange the LogUtil lib in my .8MS2 installation I get the following error when loading my test module without necessary permissions:

    Quote

    Failed to load module HelloWorld (at function: main

    When I have all permissions everything works fine.

    The pnuser.php looks like this

    Code

    function HelloWorld_user_main()
    {
        if(!(SecurityUtil::checkPermission('HelloWorld::', '::', ACCESS_OVERVIEW))) {
            return LogUtil::registerError(_MODULENOAUTH);
        }
        ...
    }

    What other files do I need to exchange to get it to work?
  • I think you need the following files:

    includes/pnAPI.php
    includes/pnAPI.php
    includes/pnobjlib/LogUtil.class.php
    includes/pnobjlib/AjaxUtil.class.php
    system/Groups/pnajax.php
    pnRender/plugins/function.pngetstatusmsg.php

    However, please note:
    1) The internal variable names have changed _PNErrorMsg and _PNStatusMsg
    2) Due to #1 the old pnSessionSetVar() calls (ie: every such call which is in the MS2 codebase) still work (in the sense that they will execute without error) but they have no effect anymore. Calling pnSessionSetVar() on _PNErrorMsg or _PNStatusMsg will trigger an error as this old-style use would overwrite the arrays with a string.

    So as you can see, these changes in turn necessitate a lot of follup-up changes. As such, it might be easiest to just grab the current CVS code ...

    Greetings
    R
  • I now got the exact same error with the complete 2006-10-17 cvs snapshot (fresh installation).



    edited by: come, Oct 18, 2006 - 04:13 AM
  • Quote

    Failed to load module HelloWorld (at function: main

    It would seem that this is an error generated somewhere in the pnModLoad() function. I'm not sure if this has anythig to do with the changes in LogUtil ...

    Do other modules work?

    Greetings
    R
  • I took the ValueAddon module News for a test and only changed the DataUtil::formatForDisplayHTML() in News_user_main() to LogUtil::registerError(). When triggering the error with insufficient permissions I get the "failed to load module" error. With the right permissions or with the DataUtil function everything works as expected.
  • Interesting. Can you please log a bug for this in the NOC and tell me as accurately as possible how to reproduce this?

    The code fundamentally works, but it seems that I've overlooked something.

    Greetings/Thanks
    R
  • Take a look at the next daily (or look at SVN) as i've done some work on bringing together the LogUtil class that Robert authored and the Errors module - the purpose of which is to display useful errors.

    LogUtil has also been extended a bit to allow for setting of some error types which result in relevant HTTP headers being sent.

    All system modules have been updated to utilise the new error handling.

    -Mark

    --
    Visit My homepage and Zikula themes.
  • 0 users

This list is based on users active over the last 60 minutes.