Page MenuHomePhabricator

Problem with external identifiers as links
Closed, ResolvedPublic

Description

Writing this on behalf of the Smithsonian:

Links to external ISNI identifiers show up as a string and not a link, even though the following was added to LocalSettings.php:

$wgWBRepoSettings['formatterUrlProperty'] = 'P45';

These instructions mention running a script, which I believe SI did:
https://www.mediawiki.org/wiki/Wikibase/Installation/Advanced_configuration#Define_links_for_external_identifiers

This problem may be reproducible. And even if the script works, @Addshore mentions that this documentation needs an update:

https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/master/docs/topics/options.md#formatterurlproperty

Related Objects

Event Timeline

danshick-wmde updated the task description. (Show Details)
danshick-wmde updated the task description. (Show Details)

@georginaburnett-wmde To be able to determine if this is a bug or user error, we need to know the exact steps followed by SI (this will be the case for any tickets filed on their behalf). Can we confirm that all of the following steps were completed?

  1. SI created a formatterURL property with datatype 'string' (I am assuming P45 in their Wikibase?)
  2. SI created An ISNI property with datatype 'external identifier'
  3. SI added a statement to the ISNI property defining the formatterURL value
    • What was input as the formatterURL value for the ISNI property?
  4. SI added a statement to [some item] pointing to its ISNI identifier
  5. SI edited localsettings.php to include $wgWBRepoSettings['formatterUrlProperty'] = 'P45';
  6. SI ran the script mentioned in the docs

Screenshots would also be very helpful in general. Once you have a chance to follow up with them, please edit the ticket or add a comment with the new details.

Samantha_Alipio_WMDE changed the task status from Open to Stalled.Nov 3 2020, 11:57 AM

Thanks for the followup. Here's hoping @ShiehJ will have her team weigh in on this.

2020-11-03

Georgina Burnett’s questions:

SI created a formatterURL property with datatype 'string' (I am assuming P45 in their Wikibase?)

SI created An ISNI property with datatype 'external identifier'

SI added a statement to the ISNI property defining the formatterURL value

What was input as the formatterURL value for the ISNI property?

SI added a statement to [some item] pointing to its ISNI identifier

SI edited localsettings.php to include $wgWBRepoSettings['formatterUrlProperty'] = 'P45';

Regarding the formatterUrlProperty setting, if we understand correctly, we added this to the LocalSettings.php

$wgWBRepoSettings['formatterUrlProperty'] = 'P45';

the local settings have been updated to the below:

$baseNs = 100;

Define the namespace indexes

define( 'WB_NS_PROPERTY', $baseNs + 2 );

define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );

Define the namespaces

$wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';

$wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';

Assigning the correct entity types to the namespaces

$wgWBRepoSettings['entityNamespaces']['item'] = NS_MAIN;

$wgWBRepoSettings['entityNamespaces']['property'] = WB_NS_PROPERTY;

After we added it, no one could edit

SI ran the script mentioned in the docs: https://www.mediawiki.org/wiki/Wikibase/Installation/Advanced_configuration#Define_links_for_external_identifiers

I hope the attach clarifies SI situation

I hope the attach clarifies SI situation

Thank you for the screenshots and additional detail! We will look into this with our team.

Samantha_Alipio_WMDE changed the task status from Stalled to Open.Nov 6 2020, 10:29 AM

I hope the attach clarifies SI situation

For convenience I am inlining the attached docx file as a comment:

2020-11-03
Georgina Burnett’s questions:

  1. SI created a formatterURL property with datatype 'string' (I am assuming P45 in their Wikibase?)

image.png (621×842 px, 86 KB)

  1. SI created An ISNI property with datatype 'external identifier'

image.png (822×850 px, 106 KB)

  1. SI added a statement to the ISNI property defining the formatterURL value
    • What was input as the formatterURL value for the ISNI property?
  2. SI added a statement to [some item] pointing to its ISNI identifier

image.png (806×720 px, 113 KB)

  1. SI edited localsettings.php to include $wgWBRepoSettings['formatterUrlProperty'] = 'P45';

Regarding the formatterUrlProperty setting, if we understand correctly, we added this to the LocalSettings.php
$wgWBRepoSettings['formatterUrlProperty'] = 'P45';
the local settings have been updated to the below:

$baseNs = 100;
 
# Define the namespace indexes
define( 'WB_NS_PROPERTY', $baseNs + 2 );
define( 'WB_NS_PROPERTY_TALK', $baseNs + 3 );
 
# Define the namespaces
$wgExtraNamespaces[WB_NS_PROPERTY] = 'Property';
$wgExtraNamespaces[WB_NS_PROPERTY_TALK] = 'Property_talk';
 
# Assigning the correct entity types to the namespaces
$wgWBRepoSettings['entityNamespaces']['item'] = NS_MAIN;  
$wgWBRepoSettings['entityNamespaces']['property'] = WB_NS_PROPERTY;

After we added it, no one could edit

  1. SI ran the script mentioned in the docs: https://www.mediawiki.org/wiki/Wikibase/Installation/Advanced_configuration#Define_links_for_external_identifiers

the local settings have been updated to the below:

Were these settings always in your local settings?
I'm guessing these are here as you are using the main namespace for your Wikibase Items, rather than the "Item" namespace?

After we added it, no one could edit

This is concerning, could you expand on this?

  • What happened when people tried to edit?

SI ran the script mentioned in the docs: https://www.mediawiki.org/wiki/Wikibase/Installation/Advanced_configuration#Define_links_for_external_identifiers

Was there any script output?
Another debugging point here would be to look in the property info table to see if the script successfully updated the table:
select * from wb_property_info where pi_property_id = 144;
You should end up seeing something like this example:
| 144 | external-id | {"type":"external-id","formatterURL":"http:\/\/www.worldwildlife.org\/ecoregions\/$1"}

One final though given the context provided here is that you may also need to purge the cache of the item your expecting to see the formatted value on (If you added the statement before setting up the formatter URL in settings).
You can do this by adding ?action=purge to the end of the URl and clicking on the button there.
For example on TEST Wikidata that would look like this https://test.wikidata.org/wiki/Q219874421?action=purge

To follow up on questions from @Samantha_Alipio_WMDE ... here's what we have.

1. SI created a formatterURL property with datatype 'string' Yes. Does the name matter? Should it be "formatterURL" or "formatter URL"? (I don't think it matters, but I want to co

Smithsonian-P45.png (1×1 px, 206 KB)

2. SI created An ISNI property with datatype 'external identifier' Yes
3. SI added a statement to the ISNI property defining the formatterURL value Yes

What was input as the formatterURL value for the ISNI property? http://isni.org/isni/$1 (and one other)

Smithsonian-P144.png (924×983 px, 99 KB)

4. SI added a statement to [some item] pointing to its ISNI identifier Yes

Smithsonian-Q1.png (1×1 px, 262 KB)

5. SI edited localsettings.php to include $wgWBRepoSettings['formatterUrlProperty'] = 'P45'; Yes

Smithsonian-LocalSettings.png (138×994 px, 80 KB)

6. SI ran the script mentioned in the docs And Yes

Smithsonian-Rebuild.png (314×2 px, 368 KB)

To follow up on questions from @Addshore ...

This is where things get more complicated, and some of this could be user error. Here's what I found:

  • All Items (Q###) are in Namespace 120 (Item:Talk is 121)
  • All Properties (P###) are in Namespace 122 (Property:Talk is 123)

Strange notes

The file ./extensions/Wikibase/repo/config/Wikibase.example.php is being used. I found this when I tried to make our LocalSettings.php file match that of our database per Advanced Configuration.

It's being included from ./extensions/Wikibase/Wikibase.php but I I think it's OK. I noticed when I ran the script and got a bunch of redefined warnings.

Database Oddity

Everything is being stored as BINARY data. Example:

mysql> select * from wb_property_info where pi_property_id = 144;
+----------------+--------------------------+------------------------------------------------+
| pi_property_id | pi_type                  | pi_info                                        |
+----------------+--------------------------+------------------------------------------------+
|            144 | 0x65787465726E616C2D6964 | 0x7B2274797065223A2265787465726E616C2D6964227D |
+----------------+--------------------------+------------------------------------------------+
1 row in set (0.00 sec)

I have to use this instead, but again, I think it's OK.

mysql> select pi_property_id, convert(pi_type using 'UTF8') as pi_type, convert(pi_info using 'UTF8') as pi_info from wb_property_info where pi_property_id = 144;
+----------------+-------------+------------------------+
| pi_property_id | pi_type     | pi_info                |
+----------------+-------------+------------------------+
|            144 | external-id | {"type":"external-id"} |
+----------------+-------------+------------------------+
1 row in set, 2 warnings (0.00 sec)

Script output:

[root@sil-viweb-wikibase html]# php extensions/Wikibase/repo/maintenance/rebuildPropertyInfo.php --rebuild-all --force
PHP Notice:  Constant WB_NS_ITEM already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 31
PHP Notice:  Constant WB_NS_ITEM_TALK already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 32
PHP Notice:  Constant WB_NS_PROPERTY already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 33
PHP Notice:  Constant WB_NS_PROPERTY_TALK already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 34
PHP Notice:  Undefined index: SERVER_NAME in /var/www/html/includes/GlobalFunctions.php on line 1350
PHP Notice:  Undefined index: SERVER_NAME in /var/www/html/includes/GlobalFunctions.php on line 1350
Updated 100 properties, up to page ID 108.
Updated 100 properties, up to page ID 208.
Updated 25 properties, up to page ID 412.
Done. Updated 225 property info entries.

It's still not working, so I'm out of ideas at this time. If someone is willing, I'm happy to get on a screen-sharing session and look over this together.

So the first thing I'll jump on is saying that this looks wrong:

PHP Notice:  Constant WB_NS_ITEM already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 31
PHP Notice:  Constant WB_NS_ITEM_TALK already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 32
PHP Notice:  Constant WB_NS_PROPERTY already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 33
PHP Notice:  Constant WB_NS_PROPERTY_TALK already defined in /var/www/html/extensions/Wikibase/repo/config/Wikibase.example.php on line 34

Are you defining these in your LocalSettings.php files?
If not could you send the lines in your LocalSettings.php file that either require_once or wfLoadExtension the Wikibase extension files?


It's being included from ./extensions/Wikibase/Wikibase.php but I I think it's OK. I noticed when I ran the script and got a bunch of redefined warnings.

You should not be loading this file.

See https://www.mediawiki.org/wiki/Wikibase/Installation#Adjust_your_LocalSettings.php


After running rebuildPropertyInfo.php the pi_info column of the property_info table should include details of the formatter URL, in your output it doesn't which is why the feature isn't working.

Could you show me the order in which all of your Wikibase config lines are set?
The $wgWBRepoSettings['formatterUrlProperty'] line should come after loading the extension files.

@Addshore This was the key bit of info I was missing:

The $wgWBRepoSettings['formatterUrlProperty'] line should come after loading the extension files.

Once I moved it to the bottom, and re-ran rebuildPropertyInfo.php the database is correct and the ISNI links out now:

Screen Shot 2020-11-17 at 10.30.05 AM.png (146×594 px, 18 KB)

In fact I moved all of the Advanced Settings to the bottom of LocalSettings.php which solves the warningsI was getting.

Thank you!

Cajunjoel claimed this task.

I also made a small update to the Advanced Configuration page.

I also made a small update to the Advanced Configuration page.

Thanks for the edit.

So yes, the settings for the extensions in general should always come after the requirement of the extension or the wfLoad call for the extension.
This applies to all of the settings (not only this one)