Last modified: 2010-05-15 15:59:48 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 T13537, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 11537 - Special:Import should have a hook
Special:Import should have a hook
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Export/Import (Other open bugs)
1.11.x
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-10-02 15:10 UTC by RV1971
Modified: 2010-05-15 15:59 UTC (History)
3 users (show)

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


Attachments
proposed patch to run a hook (1.01 KB, patch)
2007-10-16 10:12 UTC, RV1971
Details

Description RV1971 2007-10-02 15:10:26 UTC
Some extensions (for instance, http://www.mediawiki.org/wiki/Extension:DataTable)use the onArticleSaveComplete or similar triggers to modify data or store new data. This hook is not execute when importing pages through Special:Import, and Special:Import does not execute any hook. Hence, when importing such pages, one must subsequently edit and save each of them manually.

I'd suggest to create a new hook which is executed at the end of WikiRevision::importOldRevision in SpecialImport.php.
Comment 1 RV1971 2007-10-11 09:38:40 UTC
The following patch to SpecialImport.php (as of MW 1.11.0) will do. It is designed such that the parameters passed to RevisionImportComplete hooks are the same as for ArticleSaveComplete (except that some flags which are specific to manual editing will never appear). Thus, in many cases, existing extensions which use the ArticleSaveComplete hook can simply map RevisionImportComplete to the same function.

***************
*** 374,393 ****
--- 374,400 ----
  
  			wfDebug( __METHOD__ . ": running edit updates\n" );
  			$article->editUpdates(
  				$this->getText(),
  				$this->getComment(),
  				$this->minor,
  				$this->timestamp,
  				$revId );
  		}
  
+ 		$flags = ($created ? EDIT_NEW : 0) 
+ 		  | ($changed ? EDIT_UPDATE : 0)
+ 		  | ($this->minor ? EDIT_MINOR : 0);
+ 		wfRunHooks( 'RevisionImportComplete', 
+ 			    array( $article, $user, $this->getText(), 
+ 				   $this->getComment(), $flags & EDIT_MINOR, 
+ 				   null, null, &$flags, $revision ) );
  		return true;
  	}
  
  }
  
  /**
   * implements Special:Import
   * @addtogroup SpecialPage
   */
  class WikiImporter {
Comment 2 Brion Vibber 2007-10-15 23:04:49 UTC
Please post patches as attachments so they can be managed without copy/paste problems.
Comment 3 RV1971 2007-10-16 10:12:58 UTC
Created attachment 4261 [details]
proposed patch to run a hook
Comment 4 Chad H. 2008-07-22 15:17:15 UTC
Why would you pass a several nulls to the hook? What purpose does that serve?
Comment 5 RV1971 2008-07-23 09:44:18 UTC
Because (quote from comment #1): "It is designed such that the parameters passed to RevisionImportComplete hooks are
the same as for ArticleSaveComplete (except that some flags which are specific to manual editing will never appear). Thus, in many cases, existing extensions which use the ArticleSaveComplete hook can simply map RevisionImportComplete to the same function."

I can't think of many cases where the hook will be specifically needed when importing but not when saving pages, unless the purpose of the hook isd just to do extended logging of imports or similar things.
Comment 6 Siebrand Mazeland 2008-08-18 18:55:31 UTC
Mass compoment change: <some> -> Export/Import
Comment 7 Mike.lifeguard 2008-10-09 04:20:06 UTC
(In reply to comment #5)
[...]
> I can't think of many cases where the hook will be specifically needed when
> importing but not when saving pages, unless the purpose of the hook isd just to
> do extended logging of imports or similar things.
> 

Importing and saving the page are different - if there are conceivable cases where you want the import hook but you're not saving data (ie creating log entries but nothing else) then that should be possible, no?
Comment 8 RV1971 2008-10-09 08:28:46 UTC
(In reply to comment #7)

You're right, such a hook might also be useful for other purposes. Note that this is possible with the patch I suggested. In comment #1 I stated that you ''can'' map RevisionImportComplete and ArticleSaveComplete to the same function, but you are not ''forced'' to do so.
Comment 9 Mike.lifeguard 2008-11-22 19:10:54 UTC
Is this a dupe of bug 11539?
Comment 10 RV1971 2008-11-23 22:05:42 UTC
Basically yes, see comment #9 on bug 11539.
Comment 11 Aaron Schulz 2008-12-13 22:33:05 UTC
'NewRevisionFromEditComplete' was added a while back. This should inform text/revision tracking needs.
Comment 12 RV1971 2009-01-06 17:47:43 UTC
My DataTable extension (http://www.mediawiki.org/wiki/Extension:DataTable) now
uses the hook NewRevisionFromEditComplete
(http://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete), so
personally I don't have any further need for the hook suggested here.

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


Navigation
Links