Last modified: 2008-09-27 10:53:05 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T17490, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 15490 - New "ArticleEditUpdates" hook
New "ArticleEditUpdates" hook
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Page editing (Other open bugs)
1.14.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
: easy, patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-05 19:15 UTC by Juliano F. Ravasi
Modified: 2008-09-27 10:53 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Proposed patch. (555 bytes, patch)
2008-09-26 23:04 UTC, Juliano F. Ravasi
Details

Description Juliano F. Ravasi 2008-09-05 19:15:55 UTC
It would be useful to have a separate ArticleEditUpdates hook, right before the existing ArticleEditUpdatesDeleteFromRecentchanges hook in Article.php, Article::editUpdates().

This hook would be used by extensions to perform post-edit updates. Currently, the ArticleEditUpdatesDeleteFromRecentchanges is not appropriate, because it is overloaded with other purposes: any extension may want to return false from its hooked function in order to prevent old entries from being flushed from RecentChanges, and this have the side-effect of breaking any other extension depending on the same hook to perform post-edit updates.

A dedicated hook to allow extensions perform post-edit updates is then needed. Also note that ArticleSaveComplete doesn't serve for the same purpose, since there are other ways to cause edit updates that don't trigger such hook (like Import and Undelete).

I propose a new hook as:

function fnMyArticleEditUpdates(&$article, &$editInfo, $changed) { ... }

Implemented as:

========================================
--- includes/Article.php        (revision 40504)
+++ includes/Article.php        (working copy)
@@ -2713,6 +2713,8 @@
                $u = new LinksUpdate( $this->mTitle, $editInfo->output );
                $u->doUpdate();

+               wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $changed ) );
+
                if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
                        if ( 0 == mt_rand( 0, 99 ) ) {
                                // Flush old entries from the `recentchanges` table; we do this on
========================================

The rationale for passing $editInfo to the hook is so that extensions may extract data from ParserOutput collected during the parsing of the article text. $text and $newid are not passed since they are already present in $editInfo.
Comment 1 Aaron Schulz 2008-09-16 19:25:22 UTC
Can't you just use one of the LinksUpdate hooks?
Comment 2 Juliano F. Ravasi 2008-09-16 20:02:27 UTC
Hi Aaron,

I could, but it just doesn't look like the right place to do such things. In fact, I do use the LinksUpdate hook, but for updating links only.

Perhaps, the most logical place to put what I need would be "ArticleSaveComplete", but this hook have a few problems:
1. It is not called every time the article needs to perform post-edit updates (like Special:Import and Special:Undelete), this hook is more user-oriented;
2. I would have to parse $text again in order to extract the information I need from the wikitext.

The "LinksUpdate" hook has this problem:
3. It is meant to update the many links tables, it seems off to use this hook to update assorted article metadata created by the extension. Specially, it doesn't seem right to have this running during a maintenance/refreshLinks.php.

I'm currently using the "ArticleEditUpdatesDeleteFromRecentchanges" hook, that fixes problems number 1 and 3 above, and I get around problem number 2 by sneaking into $article->mPreparedEdit; but also have the drawback mentioned earlier (other extensions may shut off my extension legitimately, since this hook is for different purpose).

Note that it is part of the suggestion to pass $editInfo to this new hook. This is the important part. With this feature, I won't need to hurt any OO rules in order to get the ParserOutput object, neither will I have to parse the wikitext again.

If you would like, take a look at:
http://svn.juliano.info/svn/mediawiki/extensions/Wikilog/trunk/
* file Wikilog.php, method Wikilog::ArticleEditUpdates() and
* file WikilogLinksUpdate.php, class WikilogLinksUpdate.

If you have any better suggestion, they are welcome! I couldn't find any better way to do this.

Note that I also have *another* extension that also have to abuse the wrong hook due to the lack of the hook I propose in this bug:
http://svn.juliano.info/svn/mediawiki/extensions/KMLExport/trunk/
Comment 3 Juliano F. Ravasi 2008-09-26 23:04:33 UTC
Created attachment 5365 [details]
Proposed patch.

This is the proposed change.
Comment 4 Aaron Schulz 2008-09-27 10:53:05 UTC
Done in r41302

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links