Re: [Wikitech-l] Help me to fix a bug in my extension
On Sat, 2017-01-07 at 01:06 +0200, Victor Porton wrote: > Please help me to get my updates into Gerrit's master. > > I am confused how this works: > > https://gerrit.wikimedia.org/r/331086 > https://gerrit.wikimedia.org/r/331088 > > I will make other updates later. ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] Help me to fix a bug in my extension
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 Portonwrote: > 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 +, 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 >> 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 >> > Wikitech-l@lists.wikimedia.org >> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l >> >> ___ >> Wikitech-l mailing list >> Wikitech-l@lists.wikimedia.org >> https://lists.wikimedia.org/mailman/listinfo/wikitech-l > > > ___ > Wikitech-l mailing list > Wikitech-l@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/wikitech-l ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] Help me to fix a bug in my extension
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 +, 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> 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 > > Wikitech-l@lists.wikimedia.org > > https://lists.wikimedia.org/mailman/listinfo/wikitech-l > > ___ > Wikitech-l mailing list > Wikitech-l@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/wikitech-l ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Re: [Wikitech-l] Help me to fix a bug in my extension
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 Portonwrote: > 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 > Wikitech-l@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/wikitech-l ___ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
[Wikitech-l] Help me to fix a bug in my extension
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 Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l