Fork me on GitHub

Stacktrace error  Bottom

  • I'm trying to delete a user setting in my module, and I keep getting a Stacktrace error that I can't seem to get around...
    "Exit-Handler: DBUtil::selectObjectByID: empty id supplied Stacktrace:"

    Here's the function I'm running:

    Code

    function UserMod_user_delete($args)
    {
        $id           = (int)FormUtil::getPassedValue('id', isset($args['id']) ? $args['id'] : null, 'REQUEST');
        $confirmation = FormUtil::getPassedValue('confirmation', null, 'POST');

        // Get the existing schedule message
        $action = pnModAPIFunc('UserMod', 'user', 'getschedule', array('id' => $id));
        if ($action == false) {
            return DataUtil::formatForDisplayHTML(_NOSUCHITEM);
        }

        // Security check
        if (!SecurityUtil::checkPermission('UserMod::', "$id::", ACCESS_EDIT)) {
            return LogUtil::registerPermissionError();
        }

        // Check for confirmation.
        if (empty($confirmation)) {
            // No confirmation yet
            // Create output object
            $pnRender = pnRender::getInstance('UserMod', false);

            // Add the message id
            $pnRender->assign('id', $id);

            // assign the full item
            $pnRender->assign($action);

            // Return the output that has been generated by this function
            return $pnRender->fetch('usermod_user_delete.htm');
        }

        // Delete the banner
        // The return value of the function is checked
        if (pnModAPIFunc('UserMod', 'user', 'delete', array('id' => $id))) {
            // Success
            LogUtil::registerStatus (_USERMOD_DELETED);
        }

        // This function generated no output, and so now it is complete we redirect
        // the user to an appropriate page for them to carry on their work
        return pnRedirect(pnModURL('UserMod', 'user', 'view'));
    }
  • You should validate the $id
    to pass to userapi.getschedule a not-null value.

    I guess there's the problem, $id is null...

    --
    - Mateo T. -
    Mis principios... son mis fines
  • right...to return mixed array if id is valid, false otherwise

    Code

    function UserMod_userapi_getschedule($args)
    {
        // Argument check
        if (!isset($args['id']) || !is_numeric($args['id'])) {
            return LogUtil::registerError (_MODARGSERROR);
        }

        // get the item
        $item = DBUtil::selectObjectByID('usermod', $args['id']);

        return $item;
    }

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