Since upgrading to features 2.2 I'm getting a ton of notices as well as a PDOException whenever features is attempting to import a menu item for which a parent cannot be found in the same feature (it even throws this exception if the parent is available in another feature, or in the drupal menu_links table)

Here's the output I'm getting when enabling the feature during a drush site-install:

WD features: Rebuilding feature_name / menu_links.          [notice]
WD php: Notice: Undefined index: link_path in user_menu_link_alter()    [notice]
(line 1889 of
/var/www/freek.vanrijt/xxx/htdocs/modules/user/user.module).
WD php: Notice: Undefined index: link_path in user_menu_link_alter()    [notice]
(line 1895 of
/var/www/freek.vanrijt/xxx/htdocs/modules/user/user.module).
WD php: Notice: Undefined index: link_path in menu_link_save() (line    [notice]
3079 of
/var/www/freek.vanrijt/xxx/htdocs/includes/menu.inc).
WD php: Notice: Undefined index: link_path in menu_link_save() (line    [notice]
3079 of
/var/www/freek.vanrijt/xxx/htdocs/includes/menu.inc).
WD php: Notice: Undefined index: link_path in menu_link_save() (line    [notice]
3122 of
/var/www/freek.vanrijt/xxx/htdocs/includes/menu.inc).
WD php: PDOException: SQLSTATE[23000]: Integrity constraint              [error]
violation: 1048 Column 'link_path' cannot be null: INSERT INTO
{menu_links} (menu_name, plid, link_path, hidden, external,
has_children, expanded, weight, module, link_title, options,
customized, updated) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2,
:db_insert_placeholder_3, :db_insert_placeholder_4,
:db_insert_placeholder_5, :db_insert_placeholder_6,
:db_insert_placeholder_7, :db_insert_placeholder_8,
:db_insert_placeholder_9, :db_insert_placeholder_10,
:db_insert_placeholder_11, :db_insert_placeholder_12); Array
(
    [:db_insert_placeholder_0] => navigation
    [:db_insert_placeholder_1] => 0
    [:db_insert_placeholder_2] => 
    [:db_insert_placeholder_3] => 0
    [:db_insert_placeholder_4] => 0
    [:db_insert_placeholder_5] => 0
    [:db_insert_placeholder_6] => 0
    [:db_insert_placeholder_7] => 0
    [:db_insert_placeholder_8] => menu
    [:db_insert_placeholder_9] => 
    [:db_insert_placeholder_10] => a:0:{}
    [:db_insert_placeholder_11] => 0
    [:db_insert_placeholder_12] => 0
)
 in menu_link_save() (line 3134 of
/var/www/freek.vanrijt/xxx/htdocs/includes/menu.inc).
WD php: Warning: Cannot modify header information - headers already    [warning]
sent by (output started at /usr/local/drush/includes/output.inc:38)
in drupal_send_headers() (line 1224 of
/var/www/freek.vanrijt/xxx/htdocs/includes/bootstrap.inc).
Drush command terminated abnormally due to an unrecoverable error.       [error]

Here's the full content of the menu_links.inc file that is causing the issue:

/**
 * @file
 * feature_name.features.menu_links.inc
 */

/**
 * Implements hook_menu_default_menu_links().
 */
function feature_name_menu_default_menu_links() {
  $menu_links = array();

  // Exported menu link: main-menu_competitions:competitions
  $menu_links['main-menu_competitions:competitions'] = array(
    'menu_name' => 'main-menu',
    'link_path' => 'competitions',
    'router_path' => 'competitions',
    'link_title' => 'Competitions',
    'options' => array(
      'identifier' => 'main-menu_competitions:competitions',
    ),
    'module' => 'system',
    'hidden' => 0,
    'external' => 0,
    'has_children' => 0,
    'expanded' => 0,
    'weight' => -45,
    'customized' => 1,
    'parent_identifier' => 'main-menu_today:now',
  );
  // Translatables
  // Included for use with string extractors like potx.
  t('Competitions');


  return $menu_links;
}

Comments

FreekVR’s picture

Relating this to another issue I reported the same bug in.

codevoice’s picture

Having the same problem here as well.

mpotter’s picture

Priority: Major » Normal
pedrop’s picture

Suffering from the same problem

Håvard’s picture

Same problem

Håvard’s picture

I solved my issue by creating a new database of the correct type, utf8_unicode_ci. Perhaps someone find this information useful :)

vlad.dancer’s picture

In our case we had a corrupted menu name in the 'parent_identifier' => 'main-menu_:some_link'

kalidasan’s picture

++

donquixote’s picture

Status: Active » Postponed (maintainer needs more info)

From the issue description I do not see how the error would be caused by a problem with the parent identifier.
What I see is a missing $link['link_path'].

A stack trace would help.

Without further info, my educated guess is that this was caused by the problem described in #2509022: Undefined index in menu_links_features_rebuild_ordered
Fixed here: https://git.drupalcode.org/project/features/commit/938a7c5

So here is what I think happened:
In function menu_links_features_rebuild_ordered() we have this code:

  foreach (array_keys($ordered) as $identifier) {
    $link = $all_links[$identifier];

Without the fix from #2509022: Undefined index in menu_links_features_rebuild_ordered, it can happen that $all_links[$identifier] is not set, and then $link will be NULL. Further down some array keys are set in $link, so it becomes an incomplete menu link array, without the 'link_path' key but also without other keys.

What surprises me is that you don't get a notice for $link = $all_links[$identifier]; for an undefined array key.
All known PHP versions should produce this notice: https://3v4l.org/iIlOk (check "EOL version")
But perhaps the initial report is incomplete?

I am postponing this with needs more info.
If anyone sees this problem again, please reopen with steps to reproduce and backtrace.