Menu

#104 Namespace 0 on Wikidata

closed-fixed
None
2015-04-08
2015-02-28
No

Login to Wikidata causes a KeyNotFoundException in line 343 by the following circumstances:

  • Dictionary namespaces doesn't have a key 0 for the main namespace.
  • var aliases (e.g. in Wikibooks) doesn't have an alias.code 0 for the main namespace >> no exception.
  • var aliases in Wikidata has an alias.code 0 and alias.name "item" >> crash.

There are two work-arounds (see also feature request 29):

  1. add a KeyValuePair(0, "||") to namespaces (my proposal)
  2. or check if a key exists or doesn't

The second way could be done as follows:

foreach (var alias in aliases) {
    if(namespaces.ContainsKey(alias.code)) {
        namespaces[alias.code] += alias.name + '|';
    } else {
        namespaces[alias.code] = '|' + alias.name + '|';
    }
}

By the way, in some cases (mostly in English spoken wikis) several namespace names are doubled, e.g.:

Wikidata:
-2 >> |Media|Media|
-1 >> |Special|Special|
1 >> |Talk|Talk|Item talk|
2 >> |User|User|
3 >> |User talk|User talk|

de-Wikibooks:
8 >> |MediaWiki|MediaWiki|
102 >> |Regal|Regal|
103 >> |Regal Diskussion|Regal Diskussion|

I don't know in which cases kvp.Value is needed and splitted. Perhaps it would be better to remove double values. Juergen

Discussion

  • CodeDriller

    CodeDriller - 2015-03-02
    • status: open --> closed-accepted
     
  • CodeDriller

    CodeDriller - 2015-03-02

    Yes. I never thought that default namespace (0) could have an alias, that's weird. Nevertheless I'll add such option. I'd better add a key-value pair with key 0 to namespaces Dictionary<>.

     
  • CodeDriller

    CodeDriller - 2015-03-07
    • status: closed-accepted --> closed-fixed
     
  • CodeDriller

    CodeDriller - 2015-03-07

    Fixed in v3.14.

     

Log in to post a comment.