Jump to content

David Lumm

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by David Lumm

  1. 10 minutes ago, David Lumm said:

    I'm wondering whether AppApi is handling this as a hard error and stopping execution, but really it would carry on fine if left, or whether the situation I'm seeing is more serious than the examples in that other forum post?

    Yeah, that's exactly what's happening. In Router.php:

    public static function handleError($errNo, $errStr, $errFile, $errLine) {
            if (error_reporting()) {
                $return = new \StdClass();
                $return->error = 'Internal Server Error';
                $return->devmessage = [
                    'message' => $errStr,
                    'location' => $errFile,
                    'line' => $errLine
                ];
                self::displayOrLogError($return, 500);
            }
        }

    So if any error logging is enabled this will be fired, regardless of whether we actually care about that type of error. I've made some modifications, so I'll do a PR and you can see what you think @Sebi

    • Like 1
  2. Hi all. I've got something that I'm not 100% sure is a problem with AppApi or elsewhere, so I'm hoping someone can just help me cross the AppApi module off my list of the things I'm looking into.

    I'm currently trying get my API to send an email when a certain POST is made. Locally this works fine, but on our test server I'm getting an unexpected error:

    {
        "error": "Internal Server Error",
        "devmessage": {
            "message": "set_time_limit() has been disabled for security reasons",
            "location": "/home/runcloud/webapps/D2U-API/site/assets/cache/FileCompiler/site/modules/WireMailSmtp/WireMailSmtp.module",
            "line": 750
        }
    }

    Now a quick look through this forum suggests that this should be generating a PHP warning, that I should just be able to ignore, but for some reason it's stopping execution and generating the API error.

    I'm wondering whether AppApi is handling this as a hard error and stopping execution, but really it would carry on fine if left, or whether the situation I'm seeing is more serious than the examples in that other forum post?

    @Sebi or @thomasaull do you have any comments about how a PHP runtime warning would be handled?

  3. Hey all!

    I was wondering, is there any concept of "middleware" or hooks that I could attach to so I could run something on every request?

    At the moment I've got a couple of things I've added into every route function, but I can anticipate that list getting longer. Rather than copy and paste the same lines into each and potentially miss something, it would be great if I could run it before the route specific code runs. Is that possible @Sebi?

  4. Hi @Sebi I'm pretty new to ProcessWire and I've started using your module to add an API. I'm really appreciating all the work from you and @thomasaull as it's making my life much easier!

    I've spotted a couple of issues around HTTP statuses, one of them I've managed to do a PR for, it was pretty straightforward. The other issue is potentially a bit more complicated, or at least requires a bit of careful thought.

    Currently you can't set the response code, it's just hard-coded to 200, but I'd like to send a 201 on create. I can think of at least two ways of doing it, one is quick but messy: return the status as part of the handler response; the other is probably neater but needs choices to be made: add a function (but where? AppApiHelper?) that stores the status and then retrieve it in the router.

    Any thoughts?

    • Like 1
×
×
  • Create New...