Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#16 | fatal_error_break-2833513-16.patch | 2.82 KB | ethomas08 |
#12 | fatal_error_break-2833513-12.patch | 3.17 KB | ElusiveMind |
#3 | fatal_error_break-2833513-3.patch | 577 bytes | sudishth |
Comments
Comment #2
corentin.crouvisier CreditAttribution: corentin.crouvisier commentedSame issue for me.
Proposed patch works.
Comment #3
sudishth CreditAttribution: sudishth as a volunteer and at Azri Solutions commentedI was fixed it please review
Comment #4
salvadorweb89 CreditAttribution: salvadorweb89 commentedThanks, it works great
Comment #5
parisekI can confirm, that proposed patch works
Comment #6
jpoesen CreditAttribution: jpoesen commentedConfirming this patch works perfectly.
Comment #7
amazingrandoFWIW this patch worked for me.
Comment #8
dasha_v CreditAttribution: dasha_v at FFW for Pfizer, Inc. commentedAdded php7 tag.
Comment #9
hunlaprovo CreditAttribution: hunlaprovo commentedThanks!!! I also have 7 on php on the server. Repair is good.
Comment #10
laxman.ghavte CreditAttribution: laxman.ghavte as a volunteer and at TATA Consultancy Services commented#3 patch worked for me.
Comment #11
ElusiveMind CreditAttribution: ElusiveMind commentedThis 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
Comment #12
ElusiveMind CreditAttribution: ElusiveMind commentedNew patch with new error checking logic that ensures the return of some data even if no translations.
Comment #13
ElusiveMind CreditAttribution: ElusiveMind commentedComment #14
gdaw CreditAttribution: gdaw as a volunteer commentedPatch 12 worked great for me. RTBC +1
Comment #15
apadernoComment #16
ethomas08 CreditAttribution: ethomas08 commentedRe-rolled patch from #12 for use with 7.x-5.11 module release.
Comment #17
ethomas08 CreditAttribution: ethomas08 commentedActually scratch that it looks like the newest module release no longer includes that break command. Patch no longer necessary?