Hi,

Sorry, I said the wrong hook. ParserAfterParse comes too early in the
parse process. Try using ParserAfterTidy instead.

Also, in your onHtmlPageLinkRendererEnd function, instead of doing
things like $url = preg_replace( '/\$1/', $page, $wgArticlePath );,
you should probably do something like Title::newFromText( $page
)->getLocalUrl();

Also be careful with lines like:
  Title::newFromLinkTarget( Title::newFromText( $page ) )
Since Title::newFromText() may return false for invalid input (e.g. if
someone put [[#foo]] on a page).

--
Brian

On Fri, Jan 6, 2017 at 6:46 PM, Victor Porton <[email protected]> wrote:
> ParserAfterParse does not work either:
> https://gerrit.wikimedia.org/r/#/c/330967/
>
> It is run four times when saving an edited page, but every four times
> the list of links (which I want to amend) is empty:
>
> 2017-01-06 17:43:00 victor.local my_wiki: array(0) {
> }
> 2017-01-06 17:43:00 victor.local my_wiki: array(0) {
> }
> 2017-01-06 17:43:01 victor.local my_wiki: array(0) {
> }
> 2017-01-06 17:43:01 victor.local my_wiki: array(0) {
> }
>
> I need the list of existing links to amend it. How?
>
> On Fri, 2017-01-06 at 04:09 +0000, bawolff wrote:
>> Hi,
>>
>> You shouldn't modify the contents of the ParserOutput object from any
>> OutputPage related hook, as MediaWiki's cache system won't take the
>> new version into account correctly. Instead you should use a hook
>> called from the parser. For your use case I would suggest the
>> ParserAfterParse.
>>
>> So try changing that hook to use ParserAfterParse instead of
>> OutputPageParserOutput  (The first argument to ParserAfterParse is a
>> Parser object, call $parser->getOutput() to get the appropriate
>> ParserOutput object, and then do the exact same thing as before,
>> except delete the stuff about LinksUpdate, since MW will handle
>> LinksUpdate itself).
>>
>> Hope that helps
>> --
>> Brian
>>
>> On Thu, Jan 5, 2017 at 11:48 PM, Victor Porton <[email protected]>
>> wrote:
>> > My extension does add additional links (which it is created to
>> > render
>> > in addition to the normal [[...]] links) to the pagelinks table for
>> > the
>> > edited page every even edit and erroneously removes them back every
>> > odd
>> > edit.
>> >
>> > Please help to debug this silly behavior:
>> >
>> > https://gerrit.wikimedia.org/r/#/c/330816/1 is the patch which
>> > half-
>> > works.
>> >
>> > My extension:
>> > https://www.mediawiki.org/wiki/Extension:NamespacePopups
>> >
>> > It uses my another extension:
>> > https://www.mediawiki.org/wiki/Extension:PagePopups
>> >
>> > This is very important for me.
>> >
>> > Well, maybe some day we'll use these extensions in Wikipedia, who
>> > knows.
>> >
>> > _______________________________________________
>> > Wikitech-l mailing list
>> > [email protected]
>> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
>> _______________________________________________
>> Wikitech-l mailing list
>> [email protected]
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>
> _______________________________________________
> Wikitech-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to