Semanticmediawiki: plainlist resultformat named args regression

Created on 28 Sep 2019  路  10Comments  路  Source: SemanticMediaWiki/SemanticMediaWiki

Setup and configuration

  • SMW version: 3.1.0
  • MW version: 1.33.0
  • PHP version: 7.2.19-0ubuntu0.18.04.2
  • DB system (MySQL, Blazegraph, etc.) and version: MariaDB

Issue

http://royal-family.bitplan.com/index.php/Template:Sidebyside does not work any more - results are not displayed

Steps to reproduce

see http://royal-family.bitplan.com/index.php/Main_Page - it should show 15 royal family pictures linked to the corresponding pages but non shows.
grafik

I assume the named args behavior has changed and the arg names are not starting with? anymore or something along these lines. For debugging i added
{{{?picture|}}}

<includeonly>
{{{?picture|}}}
&#8291;[[{{{?picture|}}}|{{{userparam|150}}}px|link={{{?page|}}}]] </includeonly>
question

Most helpful comment

You could simply visit http://royal-family.bitplan.com/index.php/Special:ReplaceText and replace {{{? by {{{, probably selecting the Template namespace.

Thanks to @s7eph4n the template/list/plainlist, ol and ul formats were improved a lot in SMW 3.0.0 (a major release with expected changes - almost a year ago).

These changes were documented in SMW 3.0.0 release notes.

All 10 comments

@WolfgangFahl try to remove "?" from the parameters in the Template:Sidebyside. See the migration guide from Semantic MediaWiki 2.5.x to Semantic MediaWiki 3.0.x, specially:

  • template format becomes alias of the plainlist format
  • Removed ? as prefix for template arguments

It seems my assumption was right and http://royal-family.bitplan.com/index.php?title=Template%3ASidebyside&type=revision&diff=1332&oldid=1331 is a workaround. I'd hate to have to change dozens of other templates and wonder what motivated this change and where it (the motivation) is documented.

I'd rather see the change to be optional instead of forcing a migration. Is there some bot script available to help in the migration?

Ping @s7eph4n

You could simply visit http://royal-family.bitplan.com/index.php/Special:ReplaceText and replace {{{? by {{{, probably selecting the Template namespace.

Thanks to @s7eph4n the template/list/plainlist, ol and ul formats were improved a lot in SMW 3.0.0 (a major release with expected changes - almost a year ago).

These changes were documented in SMW 3.0.0 release notes.

@jaideraf thank you for the excellent work-around proposal. My usecase is slightly different since some of my templates are generated. The change of the generator will also be simple. I'd suggest to add a note about this migration tipp to the named args parameter explanation. https://www.semantic-mediawiki.org/wiki/Help:Named_args was just created by me to facilitate this.

By the way - i still consider it a bug that this is not configurable. The reasoning for me is like this:
If we do an impact and cost benefit analyis of the change i think the result will be:

  • the impact is on any SMW installation using the named args=yes that needs to be migrated from pre SMW 3.0 to break
  • the benefit of the new approach is marginal to those sites that have used the old style in the past
  • there is some benefit for people learning ask since it is more straight forward
  • the cost of the migration looks like being low but might be high in environments where templates are generated or where mixed version families of sites need to have a common set of templates
  • the cost of implementing support for the old style looks low to me (but I am not sure about this since i didn't look in the source code.

Here is a pywikibot/python based approach of checking the use of named args:

migrate.py

#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import pywikibot  # no need to import in user_config.py
from pywikibot import config2  # no need to import in user_config.py
from pywikibot import pagegenerators
import argparse
from bs4 import BeautifulSoup

parser = argparse.ArgumentParser(description='migrate the given wiki to SMW 3.0+')
parser.add_argument('--debug',action="store_true",help='show debug info')
parser.add_argument('--wiki', default="smw", help='the name of the wiki')
parser.add_argument('--lang', default="en", help='the language of the wiki')
parser.add_argument('--scriptpath', default="/", help='the scriptpath of the wiki')

# parse the command line arguments
args = parser.parse_args()

family = args.wiki
mylang = args.lang
familyfile=os.path.abspath(os.path.expanduser("~")+'/.pywikibot/families')+"/"+family+"_family.py"
if not os.path.isfile(familyfile):
  print ("family file %s for wiki %s is missing" % (familyfile,args.wiki))
else:
  print ("will try to use family file %s for wiki %s" % (familyfile,args.wiki))
config2.register_family_file(family, familyfile)
mysite=pywikibot.Site(mylang, family)
print("migrating templates for %s" %(mysite.sitename))
templateNameSpace=10
pages=mysite.allpages(namespace=templateNameSpace)
for page in pages:
    # https://doc.wikimedia.org/pywikibot/master/_modules/pywikibot/page.html
    title=page.title()
    ttext=page.text
    soup = BeautifulSoup(page.text,'html.parser')
    for codeNode in soup.find_all('includeonly'):
       if "{{{?" in codeNode.text:
        print ("%s has named args" % (title))

$HOME.pywikibot/families/smw_family.py

# -*- coding: utf-8  -*-
from pywikibot import family

class Family(family.Family):
    name = 'smw'
    langs = {
        'en': 'www.semantic-mediawiki.org',
    }
    def scriptpath(self, code):
       return '/w'

    def protocol(self, code):
       return 'https'

requirements.txt

# 2019-09-28
Pywikibot
beautifulsoup4

install

#!/bin/bash
# WF 2019-07-27
# install pre requisites

# install python3-yaml
# install required modules
os=$(uname -a)
case $os in
  Darwin*) 
   pip="sudo -H pip"
   install="sudo port install"
   ;;
  *) 
   pip="pip3"
   install="sudo apt-get install" 
   ;;
esac
$install python3-pip
$install python3-yaml
$pip install -r requirements.txt

To prepare follow https://www.mediawiki.org/wiki/Manual:Pywikibot and call
./install

then run
python3 migrate.py

and you'll get:

Template:Attendee has named args
Template:Conference presentations has named args
Template:Demo/Template/City/ImageShow has named args
Template:Demo/Template/City/ImageShow has named args
Template:EventBadge has named args
Template:Property has named args
Template:Query named output demo has named args
Template:Show SMW site has named args
Template:SpecialPropertyRow has named args
Template:Topic has named args
Template:Tree format with named args has named args

so even our own environment is broken :-(

ping @kghbln

This is still a show stopper for migration

Was this page helpful?
0 / 5 - 0 ratings