The data in php: // input is not equal to the data parsed and placed in $ _POST

I'm working on this weird error in Wordpress and I don't know how Wordpress works, but I stayed for an hour trying to isolate the problem and see where the root of the problem is coming from.

It turns out the problem is not that the thing is not updating, because $ _POST has no requested data.

At the top of the file I access from the browser, before any other code, I did the following:

echo file_get_contents("php://input");
print_r($_POST); exit();

      

I see that WordPress is using $ _POST as a global global and writing to it. I thought that maybe Wordpress is dumping data somewhere, but I couldn't find it. It's always at the very beginning of the file, before anything else happens at all. I don't think even variables can be changed before this

Way out of this

widget-text%5B3%5D%5Btitle%5D=Test&widget-text%5B3%5D%5Btext%5D=THISISATEST&sidebar=sidebar-1&sidebar-1_position=1&sidebar-2_position=&sidebar-3_position=&sidebar-4_position=&sidebar-5_position=&savewidget=Save+Widget&widget-id=text-3&id_base=text&multi_number=3&_wpnonce=36852083b6&_wp_http_referer=%2Fwp-admin%2Fwidgets.php%3Fmessage%3D0%26editwidget%3Dtext-3%26sidebar%3Dsidebar-1%26key%3D0
Array
(
    [widget-text] => Array
        (
            [3] => Array
                (
                    [title] => Test
                )

        )

    [sidebar] => sidebar-1
    [sidebar-1_position] => 1
    [sidebar-2_position] => 
    [sidebar-3_position] => 
    [sidebar-4_position] => 
    [sidebar-5_position] => 
    [savewidget] => Save Widget
    [widget-id] => text-3
    [id_base] => text
    [multi_number] => 3
    [_wpnonce] => 36852083b6
    [_wp_http_referer] => /wp-admin/widgets.php?message=0&editwidget=text-3&sidebar=sidebar-1&key=0
)

      

url_decoded:

widget-text[3][title]=Test&widget-text[3][text]=THISISATEST&sidebar=sidebar-1&sidebar-1_position=1&sidebar-2_position=&sidebar-3_position=&sidebar-4_position=&sidebar-5_position=&savewidget=Save Widget&widget-id=text-3&id_base=text&multi_number=3&_wpnonce=36852083b6&_wp_http_referer=/wp-admin/widgets.php?message=0&editwidget=text-3&sidebar=sidebar-1&key=0Array

      

Please note that in the original data widget-text[3][text]=THISISATEST

exists. But $_POST['widget-text']['3']['text']

- undefined.

I have looked at phpinfo and cannot find any relevant settings. I am on PHP version 5.3.8, Apache 2, I am running suse on AWS.

Does anyone have any ideas on how to make $ _POST parse the original data correctly?

+3


source to share


2 answers


This is really weird. There might be a bug in PHP or a configuration / extension issue.

  • Try to change the configuration variables max_input_nesting_level

    , max_input_vars

    , max_input_time

    . If you are not sure about the values, try using the default values. Check the PHP documentation page for defaults and their values.

  • If you are using an extension suhosin

    , try disabling it and see if it helps. All suhosin.post.*

    configuration keys are also interesting .

  • Googling shows similar problems: one , two .

  • Try to execute it through $_REQUEST

    -$_REQUEST['widget-text']['3']['text']



Anyway, after some googling, it seems to be happening in PHP 5.3.8. Thus, upgrading may be another option.

+1


source


Yup, just do:



parse_str( urldecode( file_get_contents("php://input") ), $result );

var_dump( $result );

      

+1


source







All Articles