doujing3896 2013-02-05 15:08
浏览 89
已采纳

php:// input中的数据不等于解析并放在$ _POST中的数据

I'm working out this odd bug in Wordpress, and I don't know how wordpress works, but I ran around for an hour trying to isolate the problem and see where the root of the issue comes from.

Turns out the problem is that the thing isn't updating because $_POST does not have the data that is being requested.

At the top of the file that I'm accessing 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 uses $_POST as a catch-all global and writes to it as well. I thought maybe wordpress kicks the data out somewhere but I couldn't find that. This is at the top of the file anyways, before anything else happens at all.. I don't think it's even possible for the variables to be modified before that

The output from that is

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

Note how in the raw data, widget-text[3][text]=THISISATEST exists. But $_POST['widget-text']['3']['text'] is undefined.

I looked through phpinfo and can't find any relevant settings. I am on PHP Version 5.3.8, Apache 2, I'm running suse on AWS.

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

  • 写回答

2条回答 默认 最新

  • dousong2967 2013-02-05 16:50
    关注

    This is indeed weird. Could be a bug in PHP or issue with configuration/extension.

    1. Try changing configuration variables max_input_nesting_level, max_input_vars, max_input_time. If you're unsure about values just try default ones. Check the PHP documentation page to look up default values and their meaning.

    2. If you're running suhosin extension, try disabling it and see if it helps. Also all suhosin.post.* configuration keys look interesting.

    3. Googling reveals similar problems: one, two.

    4. Try accessing it through $_REQUEST - $_REQUEST['widget-text']['3']['text']

    Anyway, after some googling it seems like this happens in PHP 5.3.8. So upgrading may be another option.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能