We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34027
    • 30 Posts
    One of the things that slows me down when I'm making a CMP is that when something breaks, there is sometimes no feedback as to what went wrong.

    I have a similar, but unrelated problem with administering site permissions. When access is denied, there is often no feedback as to why. (*)

    Here's a concrete example of where both of these issues happened simultaneously for me today.

    In connectors/index.php around line 40 there is this code:

    if (defined('MODX_REQP') && MODX_REQP === false) {
    } else if (!$modx->context->checkPolicy('load')) {
        @session_write_close();
        die();
    }
    


    Basically what this says is that "if the user doesn't have load access in this context, then fail without any feedback".



    Today I was designing a CMP and I couldn't figure out why my form submission button did nothing. Looking at firebug revealed that the the request was returning 200 OK with no content.

    Firing up XDEBUG led me to the above failed permissions check, and after a couple of hours of debugging, I found out what permissions check was failing and why.

    The bug was my own fault (**), but it was really hard to track down what was happening, in part because when I clicked that button, I got no feedback that there was even a permissions problem. And after I realized it was a permissions problem, there was no help to narrow it down what permission was failing.

    In retrospect, enabling debugging by putting $modx->setDebug(true) at the top of connectors/index.php would have been somewhat helpful as a first step. I think that how to enable debugging should be mentioned more prominently in the docs.

    Apologies for the rant. I've been complaining recently in very vague terms about MODx not providing enough feedback when something goes wrong and I finally found a specific example. I'm not sure if I should report it as a bug or not.


    Michael


    (*) There are many ways that a permissions check could have failed. Maybe it was a missing Context ACL. Or a missing Resource Group ACL. Or maybe the user was in the wrong User Group (or had the wrong role in the right group). Or maybe the resource was in the wrong resource group. Or even: maybe the resource used to be unsecured (and so was implicitly visible to everyone), but someone was granted write access to it, and that disabled implicit read access for everybody else.

    (**) The reason for the access denied was my own fault and pretty bizarre: I had copied my CMP from another modx site on my dev box, and the CMP was setting MODX_CORE_PATH to the previous site's core directory. This meant that it was actually connecting to the other site's database. So even though I was an administrator on the site I was developing for, the connector's permission check was loading all the context ACLs from the other site.
    [ed. note: michael.graham last edited this post 14 years, 6 months ago.]
      • 3749
      • 24,544 Posts
      Good points. Debugging permissions can be really frustrating and time-consuming. Unfortunately, giving feedback might provide hackers with valuable information and having a debug option would slow things down significantly.


      FYI, MODX sets MODX_CORE_PATH pretty much everywhere, so the odds are that you didn't have to set it unless you were running outside of MODX.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 34027
        • 30 Posts

        Thanks for the response, Bob.

        Hmmm... I had wondered if security was the reasoning behind the lack of feedback. I'm not sure I'm convinced.

        I don't think recording an error in a log somewhere would provide any feedback to intruders.

        At the very least I think the connector should serve up a 400 level error instead of 200 OK. That doesn't provide much information, but gives the struggling developer a hint as to why there's a blank screen.

        As for performance. I don't think writing a message to the apache error log or to the MODx log would absorb a lot of resources, especially if it only wrote to the log when access was denied (typically you don't care about performance after access has been denied).

        Anyway, I have plans for a permissions debugging system, which I hope to get around to making sooner or later.

        And I will make it so it can be disabled on production sites.

        As for the MODX_CORE_PATH, I honestly don't remember how I ended up with another config.core.php in my build directory for that project. I had thought that maybe it had something to do with my unit testing setup, or my custom table schema, but neither of those appear to be the case.
          • 3749
          • 24,544 Posts
          I look forward to seeing your permissions debugging system. I'm sure it will save people many hours of frustration.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 34027
            • 30 Posts
            I look forward to it too! smiley