Currently, there are a couple of pages (Item, Lexeme) on test Wikidata which errors when we try to index it for a search. The [frequency](https://logstash.wikimedia.org/goto/cea5a66e14ca02615a008881e4baef44) of this error over the last week was 6 times for 7 days which leads to some amount of logspam.
**Acceptance Criteria**:
- [ ] The error no longer occurs (seems to be caused by the data type changes mentioned in the comments below. See method: `Wikibase\Search\Elastic\Fields\StatementsField::getSnakAsPropertyIdAndValue`)
- [ ] After deployment, we’ve also looked at the suspected duplicate T380376 and either closed it as well (if it was fixed by the same changes) or moved it out of Stalled status (if it’s something different after all).
**Notes:**
We might be able to reproduce this locally by:
1. creating a property with data type Time
2. creating a statement with that property and a Time value
3. commenting out the `assertDataTypesCompatible()` check in `PropertyDataTypeChanger::changeDataType()`
4. using the `repo/maintenance/changePropertyDataType.php` maintenance script to change the data type of the property from Time to String
5. getting WikibaseCirrusSearch to re-index the entity with the now-broken statement, using an API call similar to the one in T372993#10104381
**Original Title / Error Message:**
TypeError: Argument 1 passed to Wikimedia\Services\ServiceContainer::{closure}() must be an instance of DataValues\StringValue, instance of DataValues\TimeValue given, called in extensions/WikibaseCirrusSearch/src/Fields/StatementsField.php:177
**Original Report**:
==== Error ====
* service.version: 1.43.0-wmf.19
* trace.id: e73b5ac6-5747-4567-a57c-68172fe4cb0f
* [[ https://logstash.wikimedia.org/app/dashboards#/view/AXFV7JE83bOlOASGccsT?_g=(time:(from:'2024-08-20T06:17:24.117Z',to:'2024-08-21T08:05:48.041Z'))&_a=(query:(query_string:(query:'reqId:%22e73b5ac6-5747-4567-a57c-68172fe4cb0f%22'))) | Find trace.id in Logstash ]]
```name=labels.normalized_message,lines=10
[{reqId}] {exception_url} TypeError: Argument 1 passed to Wikimedia\Services\ServiceContainer::{closure}() must be an instance of DataValues\StringValue, instance of DataValues\TimeValue given, called in /srv/mediawiki/php-1.43.0-wmf.19/extensions/Wikib
```
```name=error.stack_trace,lines=10
from /srv/mediawiki/php-1.43.0-wmf.19/extensions/Wikibase/repo/WikibaseRepo.datatypes.php(297)
#0 /srv/mediawiki/php-1.43.0-wmf.19/extensions/WikibaseCirrusSearch/src/Fields/StatementsField.php(177): Wikimedia\Services\ServiceContainer->{closure}(DataValues\TimeValue)
#1 /srv/mediawiki/php-1.43.0-wmf.19/extensions/WikibaseCirrusSearch/src/Fields/StatementsField.php(196): Wikibase\Search\Elastic\Fields\StatementsField->getSnakAsPropertyIdAndValue(Wikibase\DataModel\Snak\PropertyValueSnak, string)
#2 /srv/mediawiki/php-1.43.0-wmf.19/extensions/WikibaseCirrusSearch/src/Fields/StatementsField.php(132): Wikibase\Search\Elastic\Fields\StatementsField->getSnakAsString(Wikibase\DataModel\Snak\PropertyValueSnak)
#3 /srv/mediawiki/php-1.43.0-wmf.19/extensions/Wikibase/repo/includes/Content/EntityHandler.php(715): Wikibase\Search\Elastic\Fields\StatementsField->getFieldData(Wikibase\DataModel\Entity\Item)
#4 /srv/mediawiki/php-1.43.0-wmf.19/extensions/Wikibase/repo/includes/Content/EntityHandler.php(696): Wikibase\Repo\Content\EntityHandler->getContentDataForSearchIndex(Wikibase\Repo\Content\ItemContent)
#5 /srv/mediawiki/php-1.43.0-wmf.19/extensions/CirrusSearch/includes/BuildDocument/ParserOutputPageProperties.php(106): Wikibase\Repo\Content\EntityHandler->getDataForSearchIndex(WikiPage, MediaWiki\Parser\ParserOutput, CirrusSearch\CirrusSearch, MediaWiki\Revision\RevisionStoreRecord)
#6 /srv/mediawiki/php-1.43.0-wmf.19/includes/libs/objectcache/wancache/WANObjectCache.php(1729): CirrusSearch\BuildDocument\ParserOutputPageProperties->CirrusSearch\BuildDocument\{closure}(bool, int, array, null, array)
#7 /srv/mediawiki/php-1.43.0-wmf.19/includes/libs/objectcache/wancache/WANObjectCache.php(1559): WANObjectCache->fetchOrRegenerate(string, int, Closure, array, array)
#8 /srv/mediawiki/php-1.43.0-wmf.19/extensions/CirrusSearch/includes/BuildDocument/ParserOutputPageProperties.php(109): WANObjectCache->getWithSetCallback(string, int, Closure)
#9 /srv/mediawiki/php-1.43.0-wmf.19/extensions/CirrusSearch/includes/BuildDocument/ParserOutputPageProperties.php(51): CirrusSearch\BuildDocument\ParserOutputPageProperties->finalizeReal(Elastica\Document, WikiPage, CirrusSearch\CirrusSearch, MediaWiki\Revision\RevisionStoreRecord)
#10 /srv/mediawiki/php-1.43.0-wmf.19/extensions/CirrusSearch/includes/BuildDocument/BuildDocument.php(196): CirrusSearch\BuildDocument\ParserOutputPageProperties->finalize(Elastica\Document, MediaWiki\Title\Title, MediaWiki\Revision\RevisionStoreRecord)
#11 /srv/mediawiki/php-1.43.0-wmf.19/extensions/CirrusSearch/includes/Api/QueryBuildDocument.php(112): CirrusSearch\BuildDocument\BuildDocument->finalize(Elastica\Document, bool, MediaWiki\Revision\RevisionStoreRecord)
#12 /srv/mediawiki/php-1.43.0-wmf.19/includes/api/ApiQuery.php(711): CirrusSearch\Api\QueryBuildDocument->execute()
#13 /srv/mediawiki/php-1.43.0-wmf.19/includes/api/ApiMain.php(1948): ApiQuery->execute()
#14 /srv/mediawiki/php-1.43.0-wmf.19/includes/api/ApiMain.php(926): ApiMain->executeAction()
#15 /srv/mediawiki/php-1.43.0-wmf.19/includes/api/ApiMain.php(897): ApiMain->executeActionWithErrorHandling()
#16 /srv/mediawiki/php-1.43.0-wmf.19/includes/api/ApiEntryPoint.php(153): ApiMain->execute()
#17 /srv/mediawiki/php-1.43.0-wmf.19/includes/MediaWikiEntryPoint.php(200): MediaWiki\Api\ApiEntryPoint->execute()
#18 /srv/mediawiki/php-1.43.0-wmf.19/api.php(44): MediaWiki\MediaWikiEntryPoint->run()
#19 /srv/mediawiki/w/api.php(3): require(string)
#20 {main}
```
==== Impact ====
Low: Nine occurrences since first occurrence on 2024-08-01 (1.43.0-wmf.16)
==== Notes ====