Page MenuHomePhabricator

Uncaught TypeError: $(...).siteselector(...).getId is not a function
Closed, ResolvedPublic

Description

I'm trying to link https://ast.wiktionary.org/wiki/Wikcionariu:Alministradores to https://www.wikidata.org/wiki/Q4039395 using the link in the ast.wiktionary sidebar, but it won't let me and repeatedly fails with Uncaught TypeError: $(...).siteselector(...).getId is not a function. See P16260.

I've reset my local preferences and tried again (sometimes ULS errors got fixed by resetting your preferences) but it didn't work.

Given that I am not sure which specific component is triggering this error, I'm adding the tags of those that I think might be the cause.

(Note: I've tried to do this both with ?debug=true and &safemode=1 but I'm still unable to add the link).

The dialogue window that ought to display linked pages is likewise displayed empty:

Sin título.png (302×766 px, 14 KB)

Event Timeline

<s>Can you get a stracktrace with debug=true from the developer console?</s>

Sorry, did not see it was linked in a paste.

Could perhaps be https://gerrit.wikimedia.org/g/mediawiki/extensions/Wikibase/+/d130056b1d3b643955fa73aa1286780b89b2985a/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js#370

Before the error I get the following warning:

jQuery.Deferred exception: Cannot read property 'getName' of null TypeError: Cannot read property 'getName' of null

Strangely, I could link some other pages on ast.wiktionary to Wikidata without issues. It's Wikcionariu:Alministradores the only one that errors for me.

Same issue at pwn.wikipedia:

23:01:37.187 Esta página utiliza la propiedad no estándar “zoom”. Considere usar calc() en los valores de propiedad relevantes, o usar “transform” junto con “transform-origin: 0 0”. Wikipedia:na_seliyazan_a_tadedepan
23:07:13.321 jQuery.Deferred exception: site is null 
_createSiteLinkRow@https://pwn.wikipedia.org/w/load.php?debug=1&lang=es&modules=ext.uls.common%2Ci18n%2Clanguagenames%2Cmediawiki%2Cmessages%7Cjquery.i18n%2Ctipsy%2Cui%2Culs%7Cjquery.uls.grid%7Cjquery.wikibase.linkitem%7Cmw.config.values.wbRepo%2CwbSiteDetails%7Cwikibase.Site&skin=monobook&version=ztntf:662:1
$.widget/</prototype[prop]@https://pwn.wikipedia.org/w/resources/lib/jquery.ui/jquery.ui.widget.js?dcb2d:90:26
_createSiteLinkTable@https://pwn.wikipedia.org/w/load.php?debug=1&lang=es&modules=ext.uls.common%2Ci18n%2Clanguagenames%2Cmediawiki%2Cmessages%7Cjquery.i18n%2Ctipsy%2Cui%2Culs%7Cjquery.uls.grid%7Cjquery.wikibase.linkitem%7Cmw.config.values.wbRepo%2CwbSiteDetails%7Cwikibase.Site&skin=monobook&version=ztntf:639:12
$.widget/</prototype[prop]@https://pwn.wikipedia.org/w/resources/lib/jquery.ui/jquery.ui.widget.js?dcb2d:90:26
_userConfirmEntity@https://pwn.wikipedia.org/w/load.php?debug=1&lang=es&modules=ext.uls.common%2Ci18n%2Clanguagenames%2Cmediawiki%2Cmessages%7Cjquery.i18…
 undefined jquery.js:4050:18
23:07:31.449 Uncaught TypeError: $(...).siteselector(...).getId is not a function
    jQuery 43
    xhr https://pwn.wikipedia.org/w/resources/src/mediawiki.api/index.js?3bb67:297
    jQuery 6
    ajax https://pwn.wikipedia.org/w/resources/src/mediawiki.api/index.js?3bb67:269
    ajax jQuery
    ajax https://pwn.wikipedia.org/w/extensions/CentralAuth/modules/ext.centralauth.ForeignApi.js?85bda:205
    jQuery 13
load.php:481:87

Adding the link directly on Wikidata itself worked fine though.

@Lydia_Pintscher or @LucasWerkmeister - Would you be able to take a look at this one when you can? Getting the same issue at ami.wikipedia too. Thank you!

The problem here was that Q4039395 had a link to incubatorwiki (which I removed with https://www.wikidata.org/w/index.php?diff=1572146206&oldid=1572145482 … and that was fairly tedious). As we don't support linking to incubator, the client doesn't know about it (and there should be no sitelinks to it, ever).

The sitelinks were added to Q4039395 in https://www.wikidata.org/w/index.php?diff=1300509342&oldid=1290832076 (which was a merge). The sitelink was originally added in November 2020 with https://www.wikidata.org/w/index.php?oldid=1300509190. We still have 51 sitelinks to incubatorwiki which I think we should remove.

Thank you @hoo for the investigation!

Can the Community remove the remaining sitelinks on their own? If so, what would be an appropriate place where we could ask for this (and share the remaining cases)?

Can new cases still be introduced (except through reverts)? (And can it easily be fixed?)

Can the Community remove the remaining sitelinks on their own? If so, what would be an appropriate place where we could ask for this (and share the remaining cases)?

Yes (but not easily): I used the wbeditentity api with clear set and passed all existing data (minus the invalid site link). That was fairly tedious, as Q4039395 is so large that I couldn't just do this in my browser's console.

Can new cases still be introduced (except through reverts)? (And can it easily be fixed?)

No, only through reverts (unless we have an unknown bug somewhere else).

Yes (but not easily)

In this case, I would suggest we make these edits instead and inform the Community about it transparently somewhere, so they can check. @Lucas_Werkmeister_WMDE we had a discussion about this some time ago, so I would be interested if you approve? :)

I’ve tried to make the edits as a volunteer – that feels cleaner to me. I was successful on most items – see this edit group, with 40 edits (there were 51 remaining sitelinks). However, on Q4847311 I got an error that its avwiktionary sitelink no longer exists, and on Q148 I got an error that its pflwiki sitelink no longer exists (both of these can probably fixed more manually); and on Q4654925, Q5683132, Q5462387, Q2201314, Q29579, Q11725, Q11736, Q52, and Q2018526 I got inexplicable errors with no details:

failed-save: The save has failed. -- See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes.

I don’t know what to do about those items.

Here’s my code:

1#!/usr/bin/env python3
2import json
3import mwapi
4import random
5
6bot_username = 'Lucas Werkmeister@unlink-incubatorwiki_(T284211)'
7bot_password = 'redacted'
8
9edit_group_hash = '{:x}'.format(random.randrange(0, 2**48))
10edit_group = f'[[:toolforge:editgroups/b/CB/{edit_group_hash}|details]]'
11
12session = mwapi.Session('https://www.wikidata.org',
13 user_agent='unlink-incubatorwiki (mail@lucaswerkmeister.de; T284211)',
14 formatversion=1) # mwapi assumes error contents are in '*'
15lgtoken = session.get(action='query',
16 meta='tokens',
17 type='login')['query']['tokens']['logintoken']
18session.post(action='login',
19 lgname=bot_username,
20 lgpassword=bot_password,
21 lgtoken=lgtoken)
22token = session.get(action='query',
23 meta='tokens',
24 type=['csrf'])['query']['tokens']['csrftoken']
25
26def unlink_wiki(item_id, site_id):
27 item = session.get(action='wbgetentities',
28 ids=[item_id])['entities'][item_id]
29 baserevid = item['lastrevid']
30 del item['pageid'], item['ns'], item['title'], item['lastrevid'], item['modified']
31
32 try:
33 del item['sitelinks'][site_id]
34 except KeyError:
35 print(f'No {site_id} sitelink found in {item_id}.')
36 return
37
38 revid = session.post(**{
39 'action': 'wbeditentity',
40 'id': item_id,
41 'baserevid': baserevid,
42 'clear': '',
43 'data': json.dumps(item),
44 'summary': f'removing broken {site_id} sitelink ([[phabricator:T284211|T284211]], {edit_group})',
45 'assert': 'user',
46 'token': token,
47 })['entity']['lastrevid']
48 print(f'Edited {item_id}, revision {revid}.')
49
50site_id = 'incubatorwiki'
51# SELECT CONCAT("['", GROUP_CONCAT(CONCAT('Q', ips_item_id) SEPARATOR "', '"), "']") FROM wb_items_per_site WHERE ips_site_id = 'incubatorwiki';
52item_ids = ['Q4654925', 'Q5296', 'Q3055357', 'Q15117218', 'Q4847311', 'Q4608595', 'Q6064718', 'Q5462890', 'Q5056', 'Q6865035', 'Q5826993', 'Q12573042', 'Q5620924', 'Q5683132', 'Q10971517', 'Q8129125', 'Q11722212', 'Q18180967', 'Q18180953', 'Q18180959', 'Q5412328', 'Q5462387', 'Q27989948', 'Q4021091', 'Q14330485', 'Q21474049', 'Q105273306', 'Q86746352', 'Q110573516', 'Q2201314', 'Q29579', 'Q20979815', 'Q3540', 'Q956', 'Q148', 'Q11725', 'Q8686', 'Q11736', 'Q1880', 'Q20981262', 'Q52', 'Q25679189', 'Q131276', 'Q2018526', 'Q5592', 'Q10884', 'Q98713577', 'Q24905', 'Q110311413', 'Q84299498', 'Q59698']
53errors = []
54for item_id in item_ids:
55 try:
56 unlink_wiki(item_id, site_id)
57 except mwapi.errors.APIError as e:
58 print(f'Got error editing {item_id}.')
59 if not errors:
60 print('(All errors will be printed at the end. Continuing meanwhile.)')
61 errors.append(e)
62for error in errors:
63 print(error)

I’ve manually reviewed all the edits that were successfully made, as far as I can tell they look okay.

Can new cases still be introduced (except through reverts)? (And can it easily be fixed?)

No, only through reverts (unless we have an unknown bug somewhere else).

I think we do have a bug :( four of the items I edited – Q110573516, Q98713577, Q110311413, and Q84299498 – now have no sitelinks left, and look like they were initially created with the incubatorwiki sitelink (from WikibaseClient, I think?). The latest of them (the first of the four) was only created last month, on 15 January 2022, so it seems unlikely that the bug was fixed in the meantime.

I’ll also request deletion of the four items, since they don’t look notable to me.

However, on Q4847311 I got an error that its avwiktionary sitelink no longer exists, and on Q148 I got an error that its pflwiki sitelink no longer exists (both of these can probably fixed more manually)

I’ve tried to fix both of these by removing the other sitelink too, but it doesn’t work – they just produce the same failed-save error as the 9 items in that case. So we have 11 items left that I don’t know how to edit. My code:

1#!/usr/bin/env python3
2import json
3import mwapi
4import random
5
6bot_username = 'Lucas Werkmeister@unlink-incubatorwiki_(T284211)'
7bot_password = 'redacted'
8
9edit_group_hash = '372610210a06'
10edit_group = f'[[:toolforge:editgroups/b/CB/{edit_group_hash}|details]]'
11
12session = mwapi.Session('https://www.wikidata.org',
13 user_agent='unlink-incubatorwiki (mail@lucaswerkmeister.de; T284211)',
14 formatversion=1) # mwapi assumes error contents are in '*'
15lgtoken = session.get(action='query',
16 meta='tokens',
17 type='login')['query']['tokens']['logintoken']
18session.post(action='login',
19 lgname=bot_username,
20 lgpassword=bot_password,
21 lgtoken=lgtoken)
22token = session.get(action='query',
23 meta='tokens',
24 type=['csrf'])['query']['tokens']['csrftoken']
25
26def unlink_wikis(item_id, site_ids):
27 item = session.get(action='wbgetentities',
28 ids=[item_id])['entities'][item_id]
29 baserevid = item['lastrevid']
30 del item['pageid'], item['ns'], item['title'], item['lastrevid'], item['modified']
31
32 removed = []
33 for site_id in site_ids:
34 try:
35 del item['sitelinks'][site_id]
36 except KeyError:
37 print(f'No {site_id} sitelink found in {item_id}.')
38 else:
39 removed.append(site_id)
40 if not removed:
41 return
42
43 revid = session.post(**{
44 'action': 'wbeditentity',
45 'id': item_id,
46 'baserevid': baserevid,
47 'clear': '',
48 'data': json.dumps(item),
49 'summary': f'removing broken {"/".join(removed)} sitelink{"s" if len(removed) > 1 else ""} ([[phabricator:T284211|T284211]], {edit_group})',
50 'assert': 'user',
51 'token': token,
52 })['entity']['lastrevid']
53 print(f'Edited {item_id}, revision {revid}.')
54
55unlink_wikis('Q148', ['incubatorwiki', 'pflwiki'])
56unlink_wikis('Q4847311', ['incubatorwiki', 'avwiktionary'])

I found the bug leading to these site links: T301247.

I just created T301904 for finding and removing these invalid sitelinks. I suggest to close this task in favor of that one, as the specific issue mentioned here is solved.

Manuel closed this task as Resolved.EditedFeb 16 2022, 7:21 PM
Manuel claimed this task.
Manuel added a subscriber: LucasWerkmeister.

Thank you @MarcoAurelio for reporting this and thank you @LucasWerkmeister for your volunteer effort! \o/

Yes, good idea, let's make it so @hoo!

Wait, we’re not done yet are we? There’s still those 11 items linked to incubatorwiki left AFAIK.

No worries that is what the new ticket is for. It also covers other cases.

Ah, I missed that there was another ticket after T301247.

Those new T30XXXX numbers look all alike to me as well. ;)

And thx for double checking!