Page MenuHomePhabricator

Add a new parameter to Article::purge() to prevent output
Closed, ResolvedPublic

Description

Author: gm8080

Description:
This is low priority. I have already fixed this on my wiki.

Basically what I am suggesting is to add a new parameter to functions purge and doPurge in class Article in Article.php.

The problem is:
By default, the purge function outputs the article text to the page, because it was designed to be called directly on the page it's purging.

But, if one wants to purge certain pages from an extension using $articleobj->purge(), it isn't possible with the current set up without adding to the output.

Technically, someone could just use the MessageCache directly, but what if someone changes any code in the MessageCache? It would break extensions relying on this. Article::Purge() is a much better way to go for extensions.

This is what needs to be changed:

at the purge function definition:
function purge($show=true) {
and then at the "doPurge()" call inside the first IF:
$this->doPurge($show);
and then at the "} else {" where it adds the confirmation button:
} elseif($show) {
and then at the doPurge definition:
function doPurge($show=true) {
and then at the "view()" call at the end of doPurge:
if($show) $this->view();


Version: 1.12.x
Severity: enhancement

Details

Reference
bz13689

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:02 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz13689.

Why don't you call $wgOut->disable(); just before the purge() call and re-enable it afterwards?

Article::purge() is a wiki action handler, which handles action=purge.

What's probably the right thing to do here is to move the $this->view() call from Article::doPurge() back a level to Article::purge().

Assigned: brion, as he appears to have a quick solution and the overview.

Done in r39619. Used Brion's suggestion to move $this->view() up a level. Passing false to Article::purge() suppresses said output.

Reverted in r39654.

Article::purge() is a UI action entry point, not a backend method. Backend-only parameters aren't appropriate here; instead a method suitable for backend usage should be created (and/or in an ideal world, we should finish splitting Article backend stuff from UI frontend as separate classes)

Refixed in r39656.

Calling Article::doPurge() now lets the backend do a purge without output (and doesn't turn Article::purge() into a UI and backend entry, which is good)