Skip to content

Support array field value with non dot notation #55

@satrun77

Description

@satrun77

Module version

Which tagged version (or commit hash) are you using?
2.0.2

Problem statement

A field that expects an array value populated from a method returns the following error and breaks the index process.

Cannot resolve field "" on list of class "" {"exception":"[object] (LogicException(code: 0): Cannot resolve field \"\" on list of class \"\" at /var/www/html/vendor/silverstripe/silverstripe-forager/src/DataObject/DataObjectDocument.php:720)"} []

Steps to reproduce

  • Install fresh cms with Forager and Forager for Elastic
  • Elastic config
SilverStripe\Forager\Service\IndexConfiguration:
 indexes:
   main:
     includeClasses:
       Page:
         fields:
           title:
             property: Title
             options:
               type: text
           topic_ids:
             property: getPageTopicsIDs
             options:
               type: text
  • Execute Search configure
  • Execute Search reindex. The reindex fails.

Additional context

The issue is within https://github.com/silverstripeltd/silverstripe-forager/blob/main/src/DataObject/DataObjectDocument.php#L718

My quick fix to check if would work, added the following before the exception

if ($subject instanceof SS_List) {
  return [$subject, $subject->toArray()];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions