feed-me icon indicating copy to clipboard operation
feed-me copied to clipboard

Custom Source breaks Feed Map

Open Kashkin opened this issue 2 years ago • 0 comments

Description

If an Entries field has been set to use a Custom Source, an error is returned.

Trying to access array offset on value of type null

    public function getSelectOptions($options, $label = 'name', $index = 'id', $includeNone = true): array
    {
        $values = [];

        if ($includeNone) {
            if (is_string($includeNone)) {
                $values[''] = $includeNone;
            } else {
                $values[''] = 'None';
            }
        }

        if (is_array($options)) {
            foreach ($options as $value) {
                if (isset($value['optgroup'])) {
                    continue;
                }

                $values[$value[$index]] = $value[$label];
            }
        }

        return $values;
    }

Line 96 of vendor/craftcms/feed-me/src/web/twig/variables/FeedMeVariable.php.

This appears to breaks the Select field that is displayed if Create entries if they do not exist is ticked, as the field assumes a Section/Entry Type structure that is not present.

Steps to reproduce

  1. Create Custom Source on Entries screen
  2. Create Entries field that allows this custom source to be selected
  3. Assign Entries field to an Entry Type
  4. Select this Entry Type for a FeedMe import
  5. Progress to 'map' screen

Additional info

  • Craft version: 4.2.1.1
  • PHP version: 8.0
  • Database driver & version: MySQL
  • Plugins & versions: FeedMe 5.0.4

Kashkin avatar Sep 05 '22 11:09 Kashkin