While importing a CSV in a clean drupal install the following error is thrown:

Fatal error: 'break' not in the 'loop' or 'switch' context in /var/www/html/sites/all/modules/contrib/taxonomy_csv/import/taxonomy_csv.import.line.api.inc on line 377

  // Import term then store result.
  $current_result = taxonomy_csv_term_import($term, $options['update_or_ignore']);
  if (_taxonomy_csv_line_result($result, $current_result, $terms_count)) {
    break;
  }

fix:

  // Import term then store result.
  $current_result = taxonomy_csv_term_import($term, $options['update_or_ignore']);
  if (_taxonomy_csv_line_result($result, $current_result, $terms_count)) {
    return;
  }

issue:
on PHP 7 break; cant be used outside of for, foreach or switch

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blu_regard created an issue. See original summary.

corentin.crouvisier’s picture

Same issue for me.
Proposed patch works.

sudishth’s picture

Version: 7.x-5.10 » 7.x-5.x-dev
Status: Active » Needs review
FileSize
577 bytes

I was fixed it please review

salvadorweb89’s picture

Thanks, it works great

parisek’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm, that proposed patch works

jpoesen’s picture

Confirming this patch works perfectly.

amazingrando’s picture

FWIW this patch worked for me.

dasha_v’s picture

Issue tags: +php7

Added php7 tag.

hunlaprovo’s picture

Thanks!!! I also have 7 on php on the server. Repair is good.

laxman.ghavte’s picture

#3 patch worked for me.

ElusiveMind’s picture

Status: Reviewed & tested by the community » Needs work

This is pretty much a duplicate of this and needs to be fixed consistently for the same reasons outlined there.

https://www.drupal.org/project/taxonomy_csv/issues/2824032

ElusiveMind’s picture

New patch with new error checking logic that ensures the return of some data even if no translations.

ElusiveMind’s picture

Status: Needs work » Needs review
gdaw’s picture

Patch 12 worked great for me. RTBC +1

apaderno’s picture

Issue tags: -php7 +PHP 7.0 (duplicate)
ethomas08’s picture

Re-rolled patch from #12 for use with 7.x-5.11 module release.

ethomas08’s picture

Actually scratch that it looks like the newest module release no longer includes that break command. Patch no longer necessary?