Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Proxy causes save problems

I'm facing a strange bug with my setup. I use Firefox and a proxy to connect to my test page. When I try to add a new web page, a blog entry, a block, pressing the [Save] button reloads the page but doesn't create the desired entry. When doing the same with another instance of Firefox that doesn't use the proxy, the entry is saved and everything works as expected.

When I hit the [Save & continue editing] button, the entry is saved to db as expected. So it is only the Save action that doesn't work.

I'm really new to this cms and framework so I have no clue where to look at in order to do some debugging. If you can point me in the right direction (which js file to look at, where is the validation and redirection done) I would try to find out what causes that strange behavior.

Comments

  • The "Save & continue editing" button triggers an HTTP POST request behind the scenes, which you said does work. So POSTing data shouldn't be the problem.

    Can you try checking if there are javascript errors by opening the Firefox Web Console under Tools > Web Developer, clicking the settings icon and making sure "Enable persistent logs" is checked, then try saving the form again to see if there are any errors?

    My guess at the moment is some kind of input validation error, maybe relating to the CSRF token or session info.

  • When I'm trying to create a blogpost, I get TypeError: this.menu is undefined in autocomplete.js when I enter a tag. And in the console I see several GET results. One of them is that: .../validator/blog/edit: {"ts":{"not empty":"1"}}. Don't know why the timestamp (that's what ts should stand for, I guess) isn't validating.

    I'll mess around with the validator to see if I can get more info why the time stamp is empty...

  • Got it pinned down! :)

    I've gone through apps/blog/handlers/edit.php and found out that $f->submit () never evaluated to true. Then I've opened /lib/Form.php and went through the code in function submit, "debugging" with a var_dump('here...'); die; and found out that function verify_referrer never returned true for me!

    So now all I have to find out why $_SERVER['HTTP_REFERER']returns NULL in my configuration, but that has nothing to do with your fine framework - thanks for your help and I'll provide some more feedback if I find the solution for my problem.

  • Glad you've narrowed it down! Let me know if you need any help from here :)

  • Well, at first I simply hammered a return true; at the first line of Forms function verify_referrer, but then I thought it would be better to look for an elegant solution than for an ugly workaround ;-)

    I ended up with creating a bootstrap.php with following content:

    <?php
    
    /**
     *  Proxy may not send referrer. If variable is null, it is set to
     *  host. That way Form::verify_referrer() will return true which is
     *  needed to recognize submitted forms.
     */
    if ($_SERVER['HTTP_REFERER'] === null) {
        $_SERVER['HTTP_REFERER'] = $_SERVER['HTTP_HOST'];
    }
    

    I'm really happy with that!




    By the way: I created a PR on GitHub if you like to change the function so that it accepts empty referrers.

  • I think your PR is a better solution in the end. No need for a workaround then :) Thanks!

Sign In or Register to comment.