如何在编辑特定页面时触发信号/挂钩? [英] How to trigger a signal / hook on edit of a specific page?

查看:114
本文介绍了如何在编辑特定页面时触发信号/挂钩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编辑MediaWiki的特定页面之后,是否可以触发某种信号或配置一个钩子(例如执行定义的/硬编码的shell脚本)?

Is it possible to trigger some kind of signal or configure a hook (e.g. execution of defined / hard coded shell script) after editing one specific page of a MediaWiki?

情况如下.
到目前为止,每次请求RSS提要时,都会从一个特定MediaWiki页面的内容(称为wiki/index.php?title=News)生成RSS提要.由于此页面仅在几天之内被编辑一次,因此就服务器负载而言,使用Perl :: CGI oder PHP脚本作为RSS feed的源(例如,供提要阅读器的URL:example.com/rss-feed.php)应该更好.仅当维基页面被编辑后,此脚本才会生成静态RSS Feed(例如,在example.com/rss.xml处).

The scenario is as follows.
Up to now a RSS feed is generated from the content of one specific MediaWiki page (call it wiki/index.php?title=News) each time the RSS feed is requested. As this page gets edited only once in a couple of days, having a Perl::CGI oder PHP script as the source of the RSS feed (e.g. URL for feed readers: example.com/rss-feed.php) should be better - in terms of server load. This script generates a static RSS feed (e.g. at example.com/rss.xml) only when the wiki page got edited.

备注:
我正在谈论的Wiki页面受到保护,只有受信任的用户才能对其进行编辑.我无法考虑上述提议的工作流程中的安全性问题.我很高兴得到另外的说服.

Remark:
The wiki page I'm talking about is protected and only trusted users can edit it. I can not think about a security issue within the proposed workflow above. I'm happy getting otherwise convinced.

推荐答案

当然可以.

ArticleSaveComplete钩子$article参数包含标题和名称空间保存的文章中的(特别是您要访问$article->mTitle的属性).

The ArticleSaveComplete hook's $article parameter contains the title and namespace of the article that's just been saved (specifically, you want to access the properties of $article->mTitle).

使用if语句简单地定义一个函数,如果标题(和名称空间!)与给定数据不匹配,则该函数仅返回true.如果它们匹配,它将生成您需要的静态文件.

Simply define a function with an if statement that will just return true if the title (and namespace!) don't match the given data. If they do match, it will generate the static file you need.

MediaWiki Hooks手册页提供了一些示例以及有关钩子如何工作以及如何使用的更多信息.如何编写可与特定挂钩配合使用的新功能.

The MediaWiki Hooks manual page has some examples and further info on how hooks work and how to go about writing a new function that will work with a specific hook.

也就是说,我真的建议您考虑放弃这个想法,除非您实际上在计算机上看到不利的性能影响.在正常配置下,MediaWiki应该使用解析器缓存来处理此类查询中最耗费负载的操作.

That said, I would really advise you to consider dropping this idea, unless you're actually seeing adverse performance effects on your machine. Under a normal configuration, MediaWiki should use parser cache to take care of the most load-intensive operation for queries like this one.

这篇关于如何在编辑特定页面时触发信号/挂钩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆