Page MenuHomePhabricator

Adding InternalParseBeforeLinks Parser Hook for Semantic MediaWiki
Closed, ResolvedPublic

Description

Author: wilson.jim.r

Description:
As per the instructions in Semantic's INSTALL file:

Edit the file [wikipath]/includes/Parser.php. Insert the line

wfRunHooks( 'InternalParseBeforeLinks', array( &$this, &$text, null ) );

in the method "internalParse" right after the line

$text = $this->replaceVariables( $text, $args );

This is the only hack required for full functionality of Semantic MW -
everything else is already achievable with existing hooks.

I will attach a patch shortly (from revision 20529).


Version: unspecified
Severity: enhancement

Details

Reference
bz9697

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:39 PM
bzimport set Reference to bz9697.
bzimport added a subscriber: Unknown Object (MLST).

wilson.jim.r wrote:

Patch to add hook + documentation

Adds InternalParseBeforeLinks as per Semantic's INSTALL instructions.

attachment bug9697-semantic-hook.diff ignored as obsolete

wilson.jim.r wrote:

Comment on attachment 3525
Patch to add hook + documentation

Index: docs/hooks.txt

  • docs/hooks.txt (revision 20529)

+++ docs/hooks.txt (working copy)
@@ -388,6 +388,12 @@
$url: string value as output (out parameter, can modify)
$query: query options passed to Title::getFullURL()

+'InternalParseBeforeLinks': during Parser's internalParse method before links
but
+after noinclude/includeonly/onlyinclude and other processing.
+&$this: Parser object
+&$text: string containing partially parsed text
+&$this->mStripState: Parser's internal StripState object
+
'LogPageValidTypes': action being logged. DEPRECATED: Use $wgLogTypes
&$type: array of strings

Index: includes/Parser.php

  • includes/Parser.php (revision 20529)

+++ includes/Parser.php (working copy)
@@ -1000,6 +1000,7 @@

		$text = Sanitizer::removeHTMLtags( $text, array( &$this,

'attributeStripCallback' ) );

		$text = $this->replaceVariables( $text, $args );

+ wfRunHooks( 'InternalParseBeforeLinks', array( &$this, &$text,
&$this->mStripState ) );

		// Tables need to come after variable replacement for things to

work

		// properly; putting them before other transformations should

keep

wilson.jim.r wrote:

Patch to add hook

Better patch - now adds documentation in docs/hooks.txt

attachment bug9697-semantic-hook.diff ignored as obsolete

wilson.jim.r wrote:

Patch to add hook with all three params + hooks.txt and RELEASE-NOTES updates

Thanks in advance to the dev that can commit this. :)

Attached:

wilson.jim.r wrote:

Fixed in rev 21592