Hi

I prepared a CSV file where I also have columns for Metatag Description, Abstract and Keyword.
When importing them I do not get an error, but the following warnings or bugs afterwards:
1. In the log messages I get for example these warnings/information

Notice: Undefined variable: entity_type in metatag_feeds_set_target() ...... row 61 in ll/modules/metatag/metatag.feeds.inc

2. Interestingly metatag keyword is imported, but abstract and description not

3. When displaying a node with imported metatags I get sometimes these log entries

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (Zeile 124 von /includes/token.inc).

I tested this with the 7.x.-20 alpha 8 as well a version with the patch for handling spaces.

Can it be that metatag text import in general does not yet work?

thanks

Comments

megachriz’s picture

Project: Feeds » Metatag
Version: 7.x-2.0-alpha8 » 7.x-1.x-dev
Component: Code » Integration with other module

Sounds like a bug in the metatag module. Moving this issue to that project.

damienmckenna’s picture

Status: Active » Postponed (maintainer needs more info)

What version of Feeds is being used? There was a bug fixed in 1.3 (#2347193: Feeds integration borken in 1.0)?

beauregard’s picture

I am using Feeds 7.x-2.0-alpha 8
and Metatag 7.x.1.4

inversed’s picture

I recently started experiencing this with Feeds 7-x-2.x-alpha8+71-dev. What I'm seeing is that the meta tag gets written to the node as an indexed array instead of a single value. This is visible using Devel. Additionally, the imported meta tags do not display in the markup.

I get something like this (the value element is an array and it should be a string):
$node->metatags['und']['og:image']['value'][0] (String')

After editing and saving the imported node manually (without changing anything), the error goes away, in particular the error with the token.

inversed’s picture

I was in a hurry and needed a one off fix for a content import so I hacked the metatag.feeds.inc file at the bottom. In my case, I only needed a single metatag so I knew what kind of data was going through that $value.

  // Assign the value.
  $langcode = metatag_entity_get_language($entity_type, $entity);
  // convert the $value to a string and prevent empty imports (which prevent global metatag inheritance)
  $value = implode (' ' , $value );
  if (!empty($value)) {
    $entity->metatags[$langcode][$name]['value'] = $value;
  }
megachriz’s picture

The problem in #4 looks related, but has a different cause. In the dev version of Feeds, the "value" in the mapping target callback is now always an array. This is done to provide consistency across all mappers. See the change record: https://www.drupal.org/node/2301995
This change doesn't exist in Feeds 7.x-2.0-alpha8, which beauregard reports he/she is using that.

The problem in #0 seems to be caused by having the following condition FALSE:
if (!isset($entity->metatags) && !empty($entity->feeds_item->entity_id) && is_numeric($entity->feeds_item->entity_id)) {
Because after this code the variable $entity_type is used, but if the condition above results into FALSE this variable is undefined.

megachriz’s picture

Status: Postponed (maintainer needs more info) » Active
dobe’s picture

Title: Feeds import of metatag values does not work » Feeds import of metatag entity_type
StatusFileSize
new796 bytes

I ran into this issue as well. #6 brings out the correct issue. It seems that when you have an existing entity with metatag data. $entity_type does not get set.

Attached is a patch that brings the entity_type variable out of the if statement as we use it later no matter what.

dobe’s picture

Status: Active » Needs review
beauregard’s picture

I tested it, but I still have the same problems:
1. Meta Description and Meta Abstract are not imported (Meta Keyword is imported)
2. I get errors in the reports-section

I have to say that I manually adjusted metatag.feeds.inc (current active version), maybe I made an error, but as I understand only 3 lines are to be added and one to be removed.

dobe’s picture

Could you do a feed export and give a a dummy csv? That way we can test exactly what your doing. I have noticed something like this in the past if your csv is not saved using UTF-8. Without testing it though I am unsure.

beauregard’s picture

StatusFileSize
new1.05 KB

Hi, thanks for your message. Please find enclosed the two files (feed importer and file being imported)

About UTF-8: Yes, I know. This problem I had too when I started with feeds, but I know that it must be UTF-8 and I set it to UTF-8 in PSPad Editor. Besides that, importing nodes works fine.

Please note that I am using a patched version of feeds. I applied these two patches:
1. Unpublish / Delete Nodes (#204 at https://www.drupal.org/node/1470530#comment-9077209 )
2. Handle Empty Fields (https://www.drupal.org/node/1107522. The patch is in #161.)

However, when I reported this bug, I tested also with the normal most recent feeds version.

About errors:
1. Importing does not give any errors. Taxonomy terms are imported, the only thing missing is Metatag Description and Abstract
2.As soon I visit a taxonomy term page I get errors

  • Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan()
  • Warning: html_entity_decode() expects parameter 1 to be string, array given in decode_entities()
  • Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain()

The last error I got only when I called one term the first time. With other terms it did not appear.
Also the error do not appear always.

dpastov’s picture

comment #8 fix the issue. I've unfortunately missed this ticket and created my own one with exactly same fix :)
$entity_type is not set during import

damienmckenna’s picture

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks.

  • DamienMcKenna committed 3a7295d on 7.x-1.x authored by dobe
    Issue #2417155 by dobe: Feeds import fails because of placement of...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.