问题描述
我正在运行 WP 3.5.1,我有一个包含大约 100 个项目的菜单。当我向菜单中添加新项目时,旧的消失。
我没有运行 Suhosin 或类似的东西。可能是什么原因?
注意:我在专门的服务器上。
最佳解决方案
以下是为一些类似问题的用户工作的:
尝试增加 php.ini
中 max_input_vars
变量的值。该变量在 PHP 版本 5.3.9
中引入,具有默认值 1000
。
您可以在 PHP 文档中阅读更多信息:
http://php.net/manual/en/info.configuration.php
max_input_vars 1000 PHP_INI_PERDIR Available since PHP 5.3.9.
How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). Use of this directive mitigates the possibility of denial of service attacks which use hash collisions.
您可以尝试将其增加到 1500
或 2000
。
估计:
使用下面的数据,当我们按 Save Menu
按钮时,给定一定数量的菜单项,我们可以尝试估计我们发送多少个 POST 变量
好像是:
"number of POST variables" = 11 * "number of menu items" + 9
这相当于行:
y=11x+9
那么我们可以建立下表:
在您的情况下,我们看到如果您需要保存 100
菜单项,则需要发送 1109
POST 变量,因此您的 max_input_vars
必须至少为 1109
。
类似地,当我们向菜单中添加项目 (通过 Ajax POST)
我们得到
"number of POST variables" = 10 * "number of menu items" + 3
这是行:
y=10x+3
相应的数据表是:
当我们添加 10
菜单项时,我们发送 103
POST 变量。
数据:
只是为了显示 $_POST
数据量,当我保存我的菜单只有 5
项目:
Array
(
[menu-name] => simple_menu
[save_menu] => Save Menu
[closedpostboxesnonce] => xxxxxxxxxx
[meta-box-order-nonce] => xxxxxxxxxx
[update-nav-menu-nonce] => xxxxxxxxxx
[_wp_http_referer] => /dev/wp-admin/nav-menus.php
[action] => update
[menu] => 58
[menu-item-title] => Array
(
[1135] => home
[1131] => page1
[1130] => page2
[1132] => page3
[1133] => page4
)
[menu-item-attr-title] => Array
(
[1135] =>
[1131] =>
[1130] =>
[1132] =>
[1133] =>
)
[menu-item-classes] => Array
(
[1135] =>
[1131] =>
[1130] =>
[1132] =>
[1133] =>
)
[menu-item-xfn] => Array
(
[1135] =>
[1131] =>
[1130] =>
[1132] =>
[1133] =>
)
[menu-item-description] => Array
(
[1135] =>
[1131] =>
[1130] =>
[1132] =>
[1133] =>
)
[menu-item-db-id] => Array
(
[1135] => 1135
[1131] => 1131
[1130] => 1130
[1132] => 1132
[1133] => 1133
)
[menu-item-object-id] => Array
(
[1135] => 477
[1131] => 1020
[1130] => 1028
[1132] => 791
[1133] => 603
)
[menu-item-object] => Array
(
[1135] => page
[1131] => page
[1130] => page
[1132] => page
[1133] => page
)
[menu-item-parent-id] => Array
(
[1135] => 0
[1131] => 0
[1130] => 1131
[1132] => 1131
[1133] => 0
)
[menu-item-position] => Array
(
[1135] => 1
[1131] => 2
[1130] => 3
[1132] => 4
[1133] => 5
)
[menu-item-type] => Array
(
[1135] => post_type
[1131] => post_type
[1130] => post_type
[1132] => post_type
[1133] => post_type
)
[menu-locations] => Array
(
[primary] => 0
)
)
当我将 3
项目添加到菜单中时,POST
数据是:
Array
(
[action] => add-menu-item
[menu] => 58
[menu-settings-column-nonce] => xxxxxxxxxx
[menu-item] => Array
(
[-56] => Array
(
[menu-item-object-id] => 1728
[menu-item-db-id] => 0
[menu-item-object] => page
[menu-item-parent-id] => 0
[menu-item-type] => post_type
[menu-item-title] => Page 1
[menu-item-url] => http://example.com/page1/
[menu-item-target] =>
[menu-item-classes] =>
[menu-item-xfn] =>
)
[-57] => Array
(
[menu-item-object-id] => 1724
[menu-item-db-id] => 0
[menu-item-object] => page
[menu-item-parent-id] => 0
[menu-item-type] => post_type
[menu-item-title] => Page 3
[menu-item-url] => http://example.com/page2/
[menu-item-target] =>
[menu-item-classes] =>
[menu-item-xfn] =>
)
[-59] => Array
(
[menu-item-object-id] => 1658
[menu-item-db-id] => 0
[menu-item-object] => page
[menu-item-parent-id] => 0
[menu-item-type] => post_type
[menu-item-title] => Page 3
[menu-item-url] => http://example.com/page3/
[menu-item-target] =>
[menu-item-classes] =>
[menu-item-xfn] =>
)
)
)
参考文献
注:本文内容整合自 Google/Baidu/Bing 辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:薇晓朵技术论坛。