POSTed arrays keep their values

让人想犯罪 __ 提交于 2019-12-04 06:56:40

问题


Today I noticed one of my Wordpress installations is behaving in a very strange way: whenever I update a post from the Dashboard, some of its extra inputs keep the values they already have (all of them are multi-dimensional arrays). For example:

[post.php?post=123&action=edit]

<input type="text" id="field_a0b" class="text" name="fields[a][0][b]" 
value="Current value" placeholder="">

If I edit that post manually (as an end user would), changing Current value to New value, then hit the Update button, $_POST['fields']['a'][0]['b'] will still contain Current value - not New value as I would expect.

This only happens with those input arrays. Also, if I change name="fields[a][0][b]" to something random, like name="fields[a][0][bbbbbbbb]", and then print that thing, then I get the value I entered in the input field!

I've hacked Wordpress files to dump data from multiple places (even from load.php), still without success.

Not sure if this is important, but the plugin generating those HTML inputs is called ACF (Advanced Custom Fields).


回答1:


I have found in the past, if I'm reusing an array, that I should unset that array each time when I'm done with it. That way you undoubtedly clear that array for reuse.



来源:https://stackoverflow.com/questions/27935286/posted-arrays-keep-their-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!