Lucas_Werkmeister_WMDE created this task.
Lucas_Werkmeister_WMDE added projects: MediaWiki-Core-Hooks, CirrusSearch, 
Wikidata.
Restricted Application added a subscriber: Aklapper.
Restricted Application added a project: Discovery-Search.

TASK DESCRIPTION
  #cirrussearch <https://phabricator.wikimedia.org/tag/cirrussearch/>'s 
`MappingConfigBuilderTest` compares a computed mapping config with a known good 
value stored in a JSON file. To ensure that other extensions don’t interfere 
with that config, it resets several hooks:
  
    $this->mergeMwGlobalArrayValue( 'wgHooks', [
        'CirrusSearchMappingConfig' => [],
        'GetContentModels' => [],
        'SearchIndexFields' => [],
    ] );
  
  In I0209821b3e <https://gerrit.wikimedia.org/r/609208>, I’m trying to migrate 
Wikibase’s handler for the `SearchIndexFields` hook to the new hook container 
system. However, that makes that test fail:
  
    12:02:06 1) CirrusSearch\Maintenance\MappingConfigBuilderTest::testBuild 
with data set "empty" ('mapping/empty.expected', array(), 
'CirrusSearch\Maintenance\Mapp...uilder')
    12:02:06 Failed asserting that two strings are equal.
    12:02:06 --- Expected
    12:02:06 +++ Actual
    12:02:06 @@ @@
    12:02:06                      "all"\n
    12:02:06                  ]\n
    12:02:06              },\n
    12:02:06 +            "wikibase_item": {\n
    12:02:06 +                "type": "text",\n
    12:02:06 +                "analyzer": "keyword",\n
    12:02:06 +                "norms": false,\n
    12:02:06 +                "index_options": "docs"\n
    12:02:06 +            },\n
    12:02:06              "all": {\n
    12:02:06                  "type": "text",\n
    12:02:06                  "analyzer": "text",\n
    12:02:06 
    12:02:06 /workspace/src/tests/phpunit/MediaWikiTestCaseTrait.php:129
    12:02:06 
/workspace/src/extensions/CirrusSearch/tests/phpunit/integration/Maintenance/MappingConfigBuilderTest.php:61
    12:02:06 /workspace/src/tests/phpunit/MediaWikiIntegrationTestCase.php:438
    12:02:06 /workspace/src/maintenance/doMaintenance.php:107
  
  The reason for this seems to be that the `mergeMwGlobalArrayValue()` call 
doesn’t reset non-legacy hook handlers. I tried to fix this in CirrusSearch, 
but the only solution I found is this:
  
    $scopedCallback = ExtensionRegistry::getInstance()->setAttributeForTest( 
'Hooks', [] );
  
  But that feels very internal (I just found it by going through 
`HookContainer::getHandlers()` and the methods it calls), and also clears 
//all// non-legacy hook handlers, not just the three that the test is meant to 
clear. I think there should be some better way to clear hook handlers, legacy 
and non-legacy together, ideally directly in `MediaWikiIntegrationTestCase`.

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

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

To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Aklapper, Wilmanbeno, CBogen, Akuckartz, 
darthmon_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, EBjune, 
LawExplorer, _jensen, rosalieper, Scott_WUaS, Wikidata-bugs, aude, jayvdb, 
Mbch331, jeremyb
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to