WordPress 3.5默认开启XML-RPC

分享本文:

WordPress 3.5之前的WordPress版本中,XML-RPC协议默认都是关闭状态:因为开启这个功能存在安全漏洞(比如可能会导致垃圾评论和垃圾回响)。这个设置在WordPress 3.5中被修改了。

“Quite a bit has changed since we introduced off-by-default for XML-RPC. Their code has improved, and it is no longer considered a second-class citizen when it comes to API development, thanks to the work of a large team of awesome contributors. Security is no greater a concern than the rest of core.
There is no longer a compelling reason to disable this by default. It’s time we should remove the option entirely.”

(Andrew Nacin, Ticket #21509)

简单翻译一下:

“默认的 XML-RPC 的设置发生了一点变化。代码已经改进,在开发API时它们不再被当作二等公民,感谢伟大的开发团队做出的努力。安全问题的优先级不再高于其他核心问题。

再没有特别的原因,让我们有理由保持默认关闭此协议的状态。现在,是我们彻底移除这个选项的时候了。”

(Andrew Nacin, Ticket #21509)

在升级你的 WordPress 到 3.5 版本之后,enable_xmlprc,这个选项将彻底从数据库中移除。也就是说,即便你目前关闭了这项功能,也将会为你开启它。过滤器函数 pre_option_enable_xmlrpcoption_enable_xmlrpc 仍然有用(但已经被标记为“即将弃用”)。

不过,目前仍然有办法可以关闭这项服务,尽管有一点麻烦。WordPress 3.5进入新的过滤器函数enable_xmlrpc:

add_filter(‘xmlrpc_enabled’,’__return_false’);

如果你想要关闭 XML-RPC 功能的话,你可以将这个代码放到WordPress的配置文件wp-config.php文件中,放在下面这一行的下面:

require_once(ABSPATH . ‘wp-setting.php’);

更友好一些的办法是做成一个插件

WordPress还曾经支持另一个使用较少的协议“atom publishing”。这个协议的功能比XML-RPC少很多,不受开发者的喜欢。因此 WordPress 3.5 也不再支持该协议。继续使用 AtomPub 协议发布的尝试,将会受到的响应是403错误。使用 wp_atom_server 类别的插件将会受到警告:此类别即将弃用。

如果你确实仍然需要使用 AtomPub 协议支持,你可以安装一个AtomPub发布协议插件来支持。

如果你想了解更多WordPress 3.5的变化,请继续阅读图解WordPress 3.5的五大更新,以及本站的更多文章。

分享本文:


评论: WordPress 3.5默认开启XML-RPC

留言给文章 团长 取消回复

邮箱地址不会被公开。 必填项已用*标注