matthiasmullie created this task.
matthiasmullie added projects: Wikidata-Campsite, Multimedia-Current-Work, SDC 
Engineering.
Restricted Application added a subscriber: Aklapper.
Restricted Application added projects: Wikidata, Multimedia.

TASK DESCRIPTION
  ItemPropertyIdHtmlLinkFormatter and LabelsProviderEntityIdHtmlLinkFormatter's 
formatEntityId functions tries to find the label.
  When it can't find a label, it'll go out and check if the title even exists. 
If not, it'll turn to NonExistingEntityIdHtmlFormatter to format things as 
"(Deleted Item)".
  
  The exists checks are easily mislead with interwiki titles, because 
`Title::exists` will not look those up and always return false.
  I.e.: interwiki titles - if they have no label in the requested languages - 
will always render as "(Deleted Item)".
  
  It'd probably be best to use `Title::isKnown` instead of `Title::exists`.
  
  isKnown will always return true for external links.
  Just like `exists`, it won't do a lookup, but I think it makes more sense to 
treat external links as (potentially) existing (and build a valid link), than 
to treat them as non-existing when they may very well exist.
  
  An example, with `mwscript eval.php --wiki=commonswiki`
  
    $wbRepo = \Wikibase\Repo\WikibaseRepo::getDefaultInstance();
    $entityTitleLookup = $wbRepo->getEntityTitleLookup();
    $valueFormatterFactory = $wbRepo->getValueFormatterFactory();
    // id for https://www.wikidata.org/wiki/Q38622106, an item
    // with only a German (no English) label
    $entityId = \Wikibase\DataModel\Entity\ItemId::newFromNumber( 38622106 );
    $value = new \Wikibase\DataModel\Entity\EntityIdValue( $entityId );
  
  Trying to format it in German works just fine:
  
    $valueFormatterFactory->getValueFormatter( 'text/html', new 
\ValueFormatters\FormatterOptions( [ \ValueFormatters\ValueFormatter::OPT_LANG 
=> 'de' ] ) );
    var_dump( $formatter->formatValue( $value ) );
    // '<a title="d:Special:EntityPage/Q38622106" 
href="https://www.wikidata.org/wiki/Special:EntityPage/Q38622106";>Dampfwäscherei
 Südbahnhotel, Semmering</a>'
  
  In English, where there is no label, it continues to validate
  and finds that the title doesn't exist:
  
    $valueFormatterFactory->getValueFormatter( 'text/html', new 
\ValueFormatters\FormatterOptions( [ \ValueFormatters\ValueFormatter::OPT_LANG 
=> 'en' ] ) );
    $formatter->formatValue( $value );
    // 'Q38622106 <span class="wb-entity-undefinedinfo">(Deleted Item)</span>'
  
  Note the return values for $title->isLocal, ->exists and ->isKnown here:
  
    $title = $entityTitleLookup->getTitleForId( $entityId );
    var_dump( $title->isLocal() ); // true
    var_dump( $title->exists() ); // false
    var_dump( $title->isKnown() ); // true
  
  Related (SDC) ticket: T221676 <https://phabricator.wikimedia.org/T221676>

TASK DETAIL
  https://phabricator.wikimedia.org/T222138

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: matthiasmullie
Cc: matthiasmullie, Aklapper, alaa_wmde, Edtadros, Nandana, Lahi, Gq86, 
Ramsey-WMF, GoranSMilovanovic, QZanden, V4switch, LawExplorer, _jensen, 
rosalieper, Jonas, Wong128hk, Wikidata-bugs, aude, Lydia_Pintscher, 
Fabrice_Florin, Jdforrester-WMF, Matanya, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to