mirror of
				https://github.com/diocloid/LinkTitles.git
				synced 2025-10-22 05:42:32 +02:00 
			
		
		
		
	Merge pull request #53 from paladox/patch-1
Replace PageContentSave with MultiContentSave
This commit is contained in:
		
							
								
								
									
										12
									
								
								NEWS.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								NEWS.md
									
									
									
									
									
								
							@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 | 
			
		||||
 | 
			
		||||
For changes prior to version 6.0.0, please see [`NEWS.old`](news.old).
 | 
			
		||||
 | 
			
		||||
## [7.1.0][] - 2021-03-21
 | 
			
		||||
 | 
			
		||||
### Changed
 | 
			
		||||
 | 
			
		||||
- The minimum required version of MediaWiki is now 1.35.
 | 
			
		||||
 | 
			
		||||
### Fixed
 | 
			
		||||
 | 
			
		||||
- Replace PageContentSave with MultiContentSave to fix compatibility with MediaWiki 1.35.
 | 
			
		||||
- The default value for wgLinkTitlesParseOnRender is change back to `false` as support
 | 
			
		||||
  for MediaWiki 1.35+ is fixed.
 | 
			
		||||
 | 
			
		||||
## [7.0.0][] - 2020-12-23
 | 
			
		||||
 | 
			
		||||
### Changed
 | 
			
		||||
 
 | 
			
		||||
@@ -11,15 +11,15 @@
 | 
			
		||||
        ],
 | 
			
		||||
        "type": "parserhook",
 | 
			
		||||
        "url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
 | 
			
		||||
        "version": "6.0.0",
 | 
			
		||||
        "version": "7.1.0",
 | 
			
		||||
        "license-name": "GPL-2.0+",
 | 
			
		||||
        "descriptionmsg": "linktitles-desc",
 | 
			
		||||
        "requires": {
 | 
			
		||||
                "MediaWiki": ">= 1.32.0"
 | 
			
		||||
                "MediaWiki": ">= 1.35.0"
 | 
			
		||||
        },
 | 
			
		||||
        "config": {
 | 
			
		||||
                "LinkTitlesParseOnEdit": true,
 | 
			
		||||
                "LinkTitlesParseOnRender": true,
 | 
			
		||||
                "LinkTitlesParseOnRender": false,
 | 
			
		||||
                "LinkTitlesParseHeadings": false,
 | 
			
		||||
                "LinkTitlesSkipTemplates": true,
 | 
			
		||||
                "LinkTitlesPreferShortTitles": true,
 | 
			
		||||
@@ -59,8 +59,8 @@
 | 
			
		||||
                }
 | 
			
		||||
        },
 | 
			
		||||
        "Hooks": {
 | 
			
		||||
                "PageContentSave": [
 | 
			
		||||
                        "LinkTitles\\Extension::onPageContentSave"
 | 
			
		||||
                "MultiContentSave": [
 | 
			
		||||
                        "LinkTitles\\Extension::onMultiContentSave"
 | 
			
		||||
                ],
 | 
			
		||||
                "InternalParseBeforeLinks": [
 | 
			
		||||
                        "LinkTitles\\Extension::onInternalParseBeforeLinks"
 | 
			
		||||
 
 | 
			
		||||
@@ -21,8 +21,16 @@
 | 
			
		||||
 *
 | 
			
		||||
 * @author Daniel Kraus <bovender@bovender.de>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
namespace LinkTitles;
 | 
			
		||||
 | 
			
		||||
use CommentStoreComment;
 | 
			
		||||
use MediaWiki\Revision\RenderedRevision;
 | 
			
		||||
use MediaWiki\Revision\SlotRecord;
 | 
			
		||||
use Status;
 | 
			
		||||
use WikiPage;
 | 
			
		||||
use User;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provides event handlers and entry points for the extension.
 | 
			
		||||
 */
 | 
			
		||||
@@ -30,20 +38,36 @@ class Extension {
 | 
			
		||||
	const URL = 'https://github.com/bovender/LinkTitles';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Event handler for the PageContentSave hook.
 | 
			
		||||
	 * Event handler for the MultiContentSave hook.
 | 
			
		||||
	 *
 | 
			
		||||
	 * This handler is used if the parseOnEdit configuration option is set.
 | 
			
		||||
	 */
 | 
			
		||||
	public static function onPageContentSave( &$wikiPage, &$user, &$content, &$summary,
 | 
			
		||||
			$isMinor, $isWatch, $section, &$flags, &$status ) {
 | 
			
		||||
	public static function onMultiContentSave(
 | 
			
		||||
		RenderedRevision $renderedRevision,
 | 
			
		||||
		User $user,
 | 
			
		||||
		CommentStoreComment $summary,
 | 
			
		||||
		$flags,
 | 
			
		||||
		Status $hookStatus
 | 
			
		||||
	) {
 | 
			
		||||
		$isMinor = $flags & EDIT_MINOR;
 | 
			
		||||
 | 
			
		||||
		$config = new Config();
 | 
			
		||||
		if ( !$config->parseOnEdit || $isMinor ) return true;
 | 
			
		||||
 | 
			
		||||
		$revision = $renderedRevision->getRevision();
 | 
			
		||||
		$title = $revision->getPageAsLinkTarget();
 | 
			
		||||
		$slots = $revision->getSlots();
 | 
			
		||||
		$content = $slots->getContent( SlotRecord::MAIN );
 | 
			
		||||
 | 
			
		||||
		$wikiPage = WikiPage::factory( $title );
 | 
			
		||||
		$source = Source::createFromPageandContent( $wikiPage, $content, $config );
 | 
			
		||||
		$linker = new Linker( $config );
 | 
			
		||||
		$result = $linker->linkContent( $source );
 | 
			
		||||
		if ( $result ) {
 | 
			
		||||
			$content = $source->setText( $result );
 | 
			
		||||
			$slots->setContent( 'main', $content );
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user