poolghost / adminoptionspages-issues

:mag: Admin Options Pages Issue Tracker
https://adminoptionspages.com
7 stars 1 forks source link

Options page is not saving #3

Open luciana-mssouza opened 3 years ago

luciana-mssouza commented 3 years ago

Hello,

First of all, thank you very much for this plugin. The idea behind it is really great!

I tried to use it, but unfortunately, it is not saving the options page. It does not return a error, it simply does not save the configuration I sent.

When I click the button "Save" the configuration form appears again, but without the data that I inserted. I have attached 3 files with the sequence of steps I took and the result.

01 02 03

poolghost commented 3 years ago

Hey,

Thanks for trying out the plugin.

I can't replicate your issue (also not in Português do Brasil).

There must be an issue with another plugin.

Can you inspect the console (js bug) for me when you hit the save button?

Do you see some errors?

ricardopadilha commented 3 years ago

Hi, I'm helping Luciana track this bug down, and we managed to narrow it down to an incompatibility with the way we deploy Wordpress. We deploy our Wordpress instances behind a reverse proxy, using nginx and php-fpm. There are no other plugins installed, and the test environment is a vanilla Wordpress 5.8 install:

image

Can you inspect the console (js bug) for me when you hit the save button?

No errors reported at all.

Do you see some errors?

No. In fact, the Network tab shows only HTTP status 200.

Could AOP be trying to connect to itself somehow internally? Given that our deployment looks like this:

[reverse proxy] ---> [nginx] ---> [php fpm] ---> [mysql]

...if the plugin (which runs in the php fpm container) tries to connect to itself, it will fail to do so.

By the way, if I run a different docker deployment, like this:

[apache + php] ---> [mysql]

...then it works, thus my suspicion about the backend trying to connect to itself.

ricardopadilha commented 3 years ago

By the way, if you want to have a look I can give you access to the test environment we set up exclusively to troubleshoot this.

ricardopadilha commented 3 years ago

I did some more digging, and I found the reason why the option pages are not being saved: the nonce validation is failing.

The reason why the nonce validation is failing is that the frontend is not sending the nonce to the backend on save. However, it seems the frontend is sending an empty value on save because it is not reading the nonce from the HTML generated by the backend.

I can see the page-create tag in the source code just fine, but when I add some breakpoints to the javascript on the frontend, I can see that the nonce variable is not being set correctly on page load.

If I remove the nonce validation check on the backend, then I can save the option pages just fine.

ricardopadilha commented 2 years ago

It seems that the fix for #4 may also have fixed this. I'm currently testing it on a few sites, I'll update with confirmation.

ricardopadilha commented 2 years ago

Unfortunately, this is not solved by #4. The problem with nonce validation persists.

ricardopadilha commented 2 years ago

If I comment out the nonce validation in admin-options-pages/App/Validation.php like this, everything works as expected:

class Validation
{
    public function validateNonce($nonceName = '', $nonceAction = -1)
    {
        if (!isset($_POST[$nonceName]) /*|| !wp_verify_nonce($_REQUEST[$nonceName], $nonceAction)*/) {
            return false;
        }

        return true;
    }
tommy-mitchell commented 1 year ago

If I comment out the nonce validation in admin-options-pages/App/Validation.php like this, everything works as expected:

This worked perfectly, thank you!

moazam1 commented 1 year ago

Having same issue on site setup on Godaddy but works fine on local environment. On Godaddy I am using PHP 8.2.

mchev commented 1 year ago

If I comment out the nonce validation in admin-options-pages/App/Validation.php like this, everything works as expected:

class Validation
{
    public function validateNonce($nonceName = '', $nonceAction = -1)
    {
        if (!isset($_POST[$nonceName]) /*|| !wp_verify_nonce($_REQUEST[$nonceName], $nonceAction)*/) {
            return false;
        }

        return true;
    }

This quick fix not working anymore.

giannisg commented 1 month ago

If I comment out the nonce validation in admin-options-pages/App/Validation.php like this, everything works as expected:

class Validation
{
    public function validateNonce($nonceName = '', $nonceAction = -1)
    {
        if (!isset($_POST[$nonceName]) /*|| !wp_verify_nonce($_REQUEST[$nonceName], $nonceAction)*/) {
            return false;
        }

        return true;
    }

This quick fix not working anymore.

This fix worked perfectly for me.