When I export the menu with the argument --export-options throw me this Fatal error:

PHP Fatal error:  Cannot unset string offsets in /var/www/tutoriame/sites/all/modules/contrib/menu_import/includes/export.inc on line 176
PHP Stack trace:
PHP   1. {main}() /usr/share/php/drush/drush.php:0
PHP   2. drush_main() /usr/share/php/drush/drush.php:16
PHP   3. _drush_bootstrap_and_dispatch() /usr/share/php/drush/drush.php:61
PHP   4. drush_dispatch() /usr/share/php/drush/drush.php:92
PHP   5. call_user_func_array() /usr/share/php/drush/includes/command.inc:182
PHP   6. drush_command() /usr/share/php/drush/includes/command.inc:182
PHP   7. _drush_invoke_hooks() /usr/share/php/drush/includes/command.inc:214
PHP   8. call_user_func_array() /usr/share/php/drush/includes/command.inc:362
PHP   9. drush_menu_import_export() /usr/share/php/drush/includes/command.inc:362
PHP  10. menu_import_export_menu() /var/www/tutoriame/sites/all/modules/contrib/menu_import/menu_import.drush.inc:235
PHP  11. _menu_import_export_recurse() /var/www/tutoriame/sites/all/modules/contrib/menu_import/includes/export.inc:129
Drush command terminated abnormally due to an unrecoverable error.                                                     [error]
Error: Cannot unset string offsets in /var/www/tutoriame/sites/all/modules/contrib/menu_import/includes/export.inc,
line 176

Comments

lukio’s picture

Status: Active » Needs review
StatusFileSize
new698 bytes

I comment some lines of the code and fix the problem. I upload the patch.

Please, take a look and let me know if it's ok.

a.milkovsky’s picture

StatusFileSize
new582 bytes

I confirm it. You can even delete these lines as they don't make any sense.
"If something is empty - than remove it."

lukio’s picture

Assigned: Unassigned » lukio

+1 a.milkovsky

lukio’s picture

Assigned: lukio » Unassigned
lex0r’s picture

The lines do make sense, since empty will work for an empty array. However, this is not guaranteed, so I'd adjust the check to be:

      if (isset($link['options']['attributes']) && empty($link['options']['attributes'])) { // count() is only for array
         unset($link['options']['attributes']);
      }
a.milkovsky’s picture

I agree, makes sense, could you commit it?

pietrocap’s picture

Hi,
applying changes in #5 fix the error in my case :-)

eli-t’s picture

Fixed a similar issue with me, first noticed in 7.x-1.6 when exporting through the GUI, would receive a 500 error when 'Export menu item options' selected.

Stack trace

[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP Fatal error: Cannot unset string offsets in /Users/eli/Sites/sis2/sites/all/modules/contrib/menu_import/includes/export.inc on line 176, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP Stack trace:, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 1. {main}() /Users/eli/Sites/sis2/index.php:0, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 2. menu_execute_active_handler() /Users/eli/Sites/sis2/index.php:21, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 3. call_user_func_array:{/Users/eli/Sites/sis2/includes/menu.inc:517}() /Users/eli/Sites/sis2/includes/menu.inc:517, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 4. drupal_get_form() /Users/eli/Sites/sis2/includes/menu.inc:517, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 5. drupal_build_form() /Users/eli/Sites/sis2/includes/form.inc:130, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 6. drupal_process_form() /Users/eli/Sites/sis2/includes/form.inc:385, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 7. form_execute_handlers() /Users/eli/Sites/sis2/includes/form.inc:903, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 8. menu_import_export_form_submit() /Users/eli/Sites/sis2/includes/form.inc:1513, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 9. menu_import_export_menu() /Users/eli/Sites/sis2/sites/all/modules/contrib/menu_import/includes/export.inc:93, referer: https://sis2.dev/admin/structure/menu/export
[Tue Jun 24 12:12:17 2014] [error] [client 127.0.0.1] PHP 10. _menu_import_export_recurse() /Users/eli/Sites/sis2/sites/all/modules/contrib/menu_import/includes/export.inc:129, referer: https://sis2.dev/admin/structure/menu/export

Seems to work fine with the patch #2.

eli-t’s picture

Status: Needs review » Reviewed & tested by the community
a.milkovsky’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new575 bytes

as was mentioned in #5 we don't need to remove this string. We need only to add additional check.
I re-rolled the patch using #5.

eli-t’s picture

StatusFileSize
new682 bytes

Apologies, missed that. Now it does look good :)

If we want to fix the coding standards violation on the following line too we could use the patch attached to this comment: https://www.drupal.org/files/issues/menu_import-check_options-2254111-11...

lukio’s picture

+1 patch #11

a.milkovsky’s picture

Status: Needs review » Reviewed & tested by the community

reviewed

jhubley’s picture

Patch in #11 worked great. +1

lex0r’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in 7.x-1.x

  • lex0r committed 62687dd on 7.x-1.x
    Fix fatal error when --export-options is set (#2254111).
    

Status: Fixed » Closed (fixed)

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

francescosciamanna’s picture

#11 fixed my problem too. thx!