Semanticmediawiki: Invalid argument supplied for foreach() in FieldList.php on line 86

Created on 20 Oct 2020  Â·  5Comments  Â·  Source: SemanticMediaWiki/SemanticMediaWiki

Setup

Issue

Detailed description of the issue and a stack trace if applicable:

By setting a property in any page, this error occurred:

Warning: Invalid argument supplied for foreach() in /www/wwwroot/mediawiki-1.35.0/extensions/SemanticMediaWiki/src/SQLStore/EntityStore/FieldList.php on line 86
bug

Most helpful comment

Here is the call stack:

Warning: Invalid argument supplied for foreach() in /var/www/html/extensions/SemanticMediaWiki/src/SQLStore/EntityStore/FieldList.php on line 86
--
1 | 2.2327 | 406448 | {main}( ) | .../index.php:0
2 | 7.7993 | 23969680 | wfIndexMain( ) | .../index.php:46
3 | 7.8005 | 24169352 | MediaWiki->run( ) | .../index.php:53
4 | 7.8015 | 24169608 | MediaWiki->main( ) | .../MediaWiki.php:543
5 | 7.8692 | 30733672 | MediaWiki->performRequest( ) | .../MediaWiki.php:940
6 | 7.8727 | 30805456 | MediaWiki->performAction( ???, ??? ) | .../MediaWiki.php:313
7 | 7.8752 | 30818128 | ViewAction->show( ) | .../MediaWiki.php:527
8 | 7.8753 | 30883664 | Article->view( ) | .../ViewAction.php:74
9 | 7.9433 | 37271824 | MediaWiki\HookContainer\HookRunner->onArticleViewHeader( ???, ???, ??? ) | .../Article.php:719
10 | 7.9433 | 37272200 | MediaWiki\HookContainer\HookContainer->run( ???, ???, ??? ) | .../HookRunner.php:886
11 | 7.9450 | 37280512 | MediaWiki\HookContainer\HookContainer->callLegacyHook( ???, ???, ???, ??? ) | .../HookContainer.php:131
12 | 7.9450 | 37280912 | SMW\MediaWiki\Hooks->onArticleViewHeader( ???, ???, ??? ) | .../HookContainer.php:320
13 | 7.9577 | 37640248 | SMW\MediaWiki\Hooks\ArticleViewHeader->process( ???, ???, ??? ) | .../Hooks.php:711
14 | 7.9578 | 37640816 | SMW\SQLStore\EntityStore\EntityIdManager->preload( ??? ) | .../ArticleViewHeader.php:83
15 | 10.8438 | 37671824 | SMW\SQLStore\EntityStore\FieldList->getHashList( ??? ) | .../EntityIdManager.php:1128
16 | 10.8438 | 37671848 | SMW\SQLStore\EntityStore\FieldList->makeList( ???, ??? ) | .../FieldList.php:78

The code chokes at this function (because $map is an array with 516 => false here):

private function makeList( $map, &$list ) {
    foreach ( $map as $id => $values ) {
        foreach ( $values as $key => $counts ) {
            $this->matchKeyByHash( $key, $counts, $list );
        }
    }
}

$map is populated earlier in src/SQLStore/EntityStore/EntityIdManager.php, in preload:

/**
 * @since 3.2
 *
 * @param DIWikiPage[] $subjects
 *
 * @return FieldList
 */
public function preload( array $subjects ) : FieldList {

    $fieldList = $this->auxiliaryFields->prefetchFieldList(
        $subjects
    );

    $this->cacheWarmer->prefetchFromList(
        $fieldList->getHashList()
    );

    return $fieldList;
}
     $fieldList => 
SMW\SQLStore\EntityStore\FieldList
â–¼ countMaps: array(1)
  â–¼ Sandbox#0##: array(1)
       516: false

Hope it helps...!

All 5 comments

Here is the call stack:

Warning: Invalid argument supplied for foreach() in /var/www/html/extensions/SemanticMediaWiki/src/SQLStore/EntityStore/FieldList.php on line 86
--
1 | 2.2327 | 406448 | {main}( ) | .../index.php:0
2 | 7.7993 | 23969680 | wfIndexMain( ) | .../index.php:46
3 | 7.8005 | 24169352 | MediaWiki->run( ) | .../index.php:53
4 | 7.8015 | 24169608 | MediaWiki->main( ) | .../MediaWiki.php:543
5 | 7.8692 | 30733672 | MediaWiki->performRequest( ) | .../MediaWiki.php:940
6 | 7.8727 | 30805456 | MediaWiki->performAction( ???, ??? ) | .../MediaWiki.php:313
7 | 7.8752 | 30818128 | ViewAction->show( ) | .../MediaWiki.php:527
8 | 7.8753 | 30883664 | Article->view( ) | .../ViewAction.php:74
9 | 7.9433 | 37271824 | MediaWiki\HookContainer\HookRunner->onArticleViewHeader( ???, ???, ??? ) | .../Article.php:719
10 | 7.9433 | 37272200 | MediaWiki\HookContainer\HookContainer->run( ???, ???, ??? ) | .../HookRunner.php:886
11 | 7.9450 | 37280512 | MediaWiki\HookContainer\HookContainer->callLegacyHook( ???, ???, ???, ??? ) | .../HookContainer.php:131
12 | 7.9450 | 37280912 | SMW\MediaWiki\Hooks->onArticleViewHeader( ???, ???, ??? ) | .../HookContainer.php:320
13 | 7.9577 | 37640248 | SMW\MediaWiki\Hooks\ArticleViewHeader->process( ???, ???, ??? ) | .../Hooks.php:711
14 | 7.9578 | 37640816 | SMW\SQLStore\EntityStore\EntityIdManager->preload( ??? ) | .../ArticleViewHeader.php:83
15 | 10.8438 | 37671824 | SMW\SQLStore\EntityStore\FieldList->getHashList( ??? ) | .../EntityIdManager.php:1128
16 | 10.8438 | 37671848 | SMW\SQLStore\EntityStore\FieldList->makeList( ???, ??? ) | .../FieldList.php:78

The code chokes at this function (because $map is an array with 516 => false here):

private function makeList( $map, &$list ) {
    foreach ( $map as $id => $values ) {
        foreach ( $values as $key => $counts ) {
            $this->matchKeyByHash( $key, $counts, $list );
        }
    }
}

$map is populated earlier in src/SQLStore/EntityStore/EntityIdManager.php, in preload:

/**
 * @since 3.2
 *
 * @param DIWikiPage[] $subjects
 *
 * @return FieldList
 */
public function preload( array $subjects ) : FieldList {

    $fieldList = $this->auxiliaryFields->prefetchFieldList(
        $subjects
    );

    $this->cacheWarmer->prefetchFromList(
        $fieldList->getHashList()
    );

    return $fieldList;
}
     $fieldList => 
SMW\SQLStore\EntityStore\FieldList
â–¼ countMaps: array(1)
  â–¼ Sandbox#0##: array(1)
       516: false

Hope it helps...!

Forgot to say that this is reproduced on a production environment with SMW 3.2.2 + MW 1.35.1 : https://wiki.preprod.tripleperformance.fr/wiki/Sp%C3%A9cial:Version (see the bug there: https://wiki.preprod.tripleperformance.fr/wiki/Accueil)

Did you find a workaround for this issue? Do you know whether it is causing any actual problems?

looks like a run of maintenance/updateEntityCountMap.php fixed it for me, maybe the initial run I did failed somehow?

Hello Sebastian, no - I must admin those are bits of code I don't dare to touch...!

I simply hid the warning for now, but didn't cure the cause.

I just tried running maintenance/updateEntityCountMap.php, but it didn't fix the problem.

Was this page helpful?
0 / 5 - 0 ratings