Semanticmediawiki: Wikitext not parsed on "Special:Ask" when used with `intro` parameter

Created on 23 Apr 2020  ·  14Comments  ·  Source: SemanticMediaWiki/SemanticMediaWiki

Setup and configuration

  • SMW version: 3.0.0
  • MW version: 1.31.1
  • PHP version: 7.2.25 (cgi-fcgi)
  • DB system (MySQL, Blazegraph, etc.) and version: 10.1.40-MariaDB

Issue

{{#ask: ... |intro = [[page]] }} works on the inline query page, but not on Spezial:Semantische_Suche. Here the result is a printout of <a href="/wiki/page">Page</a>

Steps to reproduce

https://www.univie.ac.at/rel_jap/an/Metalog:Bilder/Skulptur (click on "Weitere Ergebnisse")

bug

Most helpful comment

This issue here is solely related to the Special:Ask output.

With this change, all fixed in Special:Ask! :100:

All 14 comments

@jaideraf I remember we had something like this before but cannot remember exactly. I think it was you who came up with it.

No, I think you are referring to this issue (my question was about intro not going to the output in the templatefile format).

Actually I think this is a new issue, we can reproduce it on sandbox:
https://sandbox.semantic-mediawiki.org/wiki/Issue/4738

Thanks for answering and creating an example on sandbox! Still I have the feeling we had this before. I think @krabina is our second expert in this field. Perhaps it was him which issues here in the past. Senior moments with no end I'm afraid.

Still I have the feeling we had this before. I

Question, what integration tests we have with intro / outro? Any of those test containing a wikitext notation and a test with Special:Ask (see the S section to test the output for special pages)?

s-0011.json chekcs intro / outro for table format in three cases:

#1 (parse [[ ... ]] as links in intro/outro)
#2 (parse URL in intro/outro)
#3 (parse template in intro/outro)

I expanded this text file to also test the list, plainlist, ol and ul formats. Should I send a PR? (I did not provide a fix, I don't know PHP).

EDIT: I sent it, anyway. Feel free to refuse it if the policy is not merging without providing a fix.

Thank you. Actually, I use “plainlist” format combined with “template”.

I think the working solution is introtemplate rather than intro when using wikicode. Still, it is a kind of bug…

Best

Bernhard Scheid

The following change could provide a remedy but I haven't tested it and don't know whether this impacts existing intro/outro outputs.

@@ -380,20 +380,20 @@ abstract class ResultPrinter implements IResultPrinter {
        );

        // Apply intro parameter
        if ( ( $this->mIntro ) && ( $results->getCount() > 0 ) ) {
            if ( $outputmode == SMW_OUTPUT_HTML ) {
-               $result = Message::get( [ 'smw-parse', $this->mIntro ], Message::PARSE ) . $result;
+               $result = $this->recursiveTextProcessor->recursivePreprocess( $this->mIntro ) . $result;
            } elseif ( $outputmode !== SMW_OUTPUT_RAW ) {
                $result = $this->mIntro . $result;
            }
        }

        // Apply outro parameter
        if ( ( $this->mOutro ) && ( $results->getCount() > 0 ) ) {
            if ( $outputmode == SMW_OUTPUT_HTML ) {
-               $result = $result . Message::get( [ 'smw-parse', $this->mOutro ], Message::PARSE );
+               $result = $result . $this->recursiveTextProcessor->recursivePreprocess( $this->mOutro );
            } elseif ( $outputmode !== SMW_OUTPUT_RAW ) {
                $result = $result . $this->mOutro;
            }
        }

@mwjames I confirm, this does fix for the list, plainlist, ol and ul formats (and possibly others) in normal pages _and_ Special:Ask.

Breaks table / broadtable in Special:Ask only: they show something like:
[[SMW::off]][[Wikincat:Home|Home]][[SMW::on]]

And datatables format shows only:
[[Wikincat:Home|Home]] in normal pages (still bad)
and
[[SMW::off]][[Wikincat:Home|Home]][[SMW::on]] in in Special:Ask.

Breaks table / broadtable in Special:Ask only: they show something like:

Okay, I conclude that this issue is with the list printer since the above change apparently only fixes "list, plainlist, ol and ul" but makes all other formats to render a wrong output.

It relates of how a printer uses/sets $this->isHTML (list printer and table printer have different settings for this attribute during an output) therefore try:

@@ -379,20 +379,20 @@ abstract class ResultPrinter implements IResultPrinter {
            $this->recursiveAnnotation
        );

        // Apply intro parameter
        if ( ( $this->mIntro ) && ( $results->getCount() > 0 ) ) {
-           if ( $outputmode == SMW_OUTPUT_HTML ) {
+           if ( $outputmode == SMW_OUTPUT_HTML && $this->isHTML ) {
                $result = Message::get( [ 'smw-parse', $this->mIntro ], Message::PARSE ) . $result;
            } elseif ( $outputmode !== SMW_OUTPUT_RAW ) {
                $result = $this->mIntro . $result;
            }
        }

        // Apply outro parameter
        if ( ( $this->mOutro ) && ( $results->getCount() > 0 ) ) {
-           if ( $outputmode == SMW_OUTPUT_HTML ) {
+           if ( $outputmode == SMW_OUTPUT_HTML && $this->isHTML ) {
                $result = $result . Message::get( [ 'smw-parse', $this->mOutro ], Message::PARSE );
            } elseif ( $outputmode !== SMW_OUTPUT_RAW ) {
                $result = $result . $this->mOutro;
            }
        }

Ok, I will.

I conclude that this issue is with the list printer

There is also the valuerank related issue.

it prints a list of all occuring values, with duplicates removed, together with their occurrence count. It is derived from result format "tagcloud" [0]

I don't know if valuerank code also has some shared code with list printer. Maybe you should have a look after I test this new change you have proposed.

[0] https://www.semantic-mediawiki.org/wiki/Help:Valuerank_format

I don't know if valuerank code also

I don't think so.

There is also the valuerank related issue.

This relates to embedded output as far as I can see from the provided context. This issue here is solely related to the Special:Ask output.

This issue here is solely related to the Special:Ask output.

With this change, all fixed in Special:Ask! :100:

Was this page helpful?
0 / 5 - 0 ratings