Notice: Undefined index: link_override__title in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromSharedTables

Created on 19 January 2022, over 2 years ago
Updated 30 January 2024, 5 months ago

Problem

Updated from Drupal 8 to 9 and when I tried clearing cache I get this notice:

Notice: Undefined index: link_override__title in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromSharedTables() (line 602 of core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).
Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromSharedTables(Array, Array, ) (Line: 501)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->mapFromStorageRecords(Array) (Line: 427)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->getFromStorage(Array) (Line: 393)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple(Array) (Line: 346)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 66)
Drupal\menu_link_content\Plugin\Deriver\MenuLinkContentDeriver->getDerivativeDefinitions(Array) (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives(Array) (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 164)
Drupal\Core\Menu\MenuLinkManager->getDefinitions() (Line: 189)
Drupal\Core\Menu\MenuLinkManager->rebuild() (Line: 82)...
Notice: Undefined index: link_override__options in Drupal\Core\Entity\Sql\SqlContentEntityStorage

I noticed the table is missing the column when we updated to Drupal 9 in version 2.0.0 and thinking of just adding the columns through a custom module.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States djmymy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    I wasn't able to reproduce. Waiting for further feedback.

  • Status changed to Closed: outdated over 1 year ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Let's close this outdated for that reason. @djmymy didn't respond > 1Y

  • πŸ‡ΊπŸ‡ΈUnited States djmymy

    Hi, so sorry just got notification. I believe the previous developer used 1.x version, and currently, it is under 2.x. Still have the issue. I tried the drush entity update, but it did not work.

  • Status changed to Active over 1 year ago
  • miiimooo Europe

    I'm also seeing this with 2.0.0

    @djmymy did reverting to 1.x version help for you?

    I think this could be related to running on PHP 8.1
    Deprecated function: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromSharedTables()

  • Status changed to Needs review over 1 year ago
  • miiimooo Europe

    The update hook proposed in this issue πŸ› Invalid values given. Values must be represented as an associative array. Fixed fixed this issue for me. I am not sure I understand the exact logic there but maybe you could test it too and report if it fixes your problem

  • πŸ‡ΊπŸ‡ΈUnited States djmymy

    Thanks @miiimooo! Unfortunately no luck, I also tried to revert but due to being on the latest drupal 9 and PHP 8.1 it won't let me go back. I tried the patches but get errors. When I tried a drush entup I got this. Going to keep investigating. Thanks again though! I'll def update the solution here if I find it.

    Exception thrown while performing a schema update. SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'link_override__uri' doesn't exist in table: ALTER
       TABLE "menu_link_content_field_revision" ADD INDEX `menu_link_content_field__link_override__uri` (`link_override__uri`(30)); Array
      (
      )
    
    
    SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'link_override__uri' doesn't exist in table
    
  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    Hmm, I tried to reproduce problem - and it seems that indeed, 1.x to 2.x path is broken. I was able to run into some errors regarding field doesn't exist.

  • @jsobiecki opened merge request.
  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    Hi, I just opened MR against 2.x branch. It should provide update from 1.x to 2.x version. Please review if it's fixing your issues. If everything will be OK, I'll merge it in 2.x.

  • πŸ‡ΊπŸ‡ΈUnited States djmymy

    hi @jsobiecki,
    I noticed something strange when I noticed inside the folder the translatable_menu_link_uri.install file is missing. I ran composer again and even tried to download the file zip and tar file and noticed that one file was missing in the installation. When I forced added it and ran your commit as a patch I got this error:

    drush updb
     ---------------------------- ----------- --------------- -------------
      Module                       Update ID   Type            Description
     ---------------------------- ----------- --------------- -------------
      translatable_menu_link_uri   9003        hook_update_n   9003 -
     ---------------------------- ----------- --------------- -------------
    
    
     Do you wish to run the specified pending updates? (yes/no) [yes]:
     > yes
    
    >  [notice] Update started: translatable_menu_link_uri_update_9003
    >  [error]  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mlcd.link_override__options' in 'field list': SELECT "mlcd"."id" AS "id", "mlcd"."link__options" AS "link__options", "mlcd"."link_override__options" AS "link_override__options"
    > FROM
    > "menu_link_content_field_revision" "mlcd"; Array
    > (
    > )
    >
    >  [error]  Update failed: translatable_menu_link_uri_update_9003
     [error]  Update aborted by: translatable_menu_link_uri_update_9003
     [error]  Finished performing updates.
  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    Hello @djmymy The fix is not been commited yet. There should be two updates on your list, I see only one.

    Please make sure you applied this patch: https://git.drupalcode.org/project/translatable_menu_link_uri/-/merge_re....

    If updatedb will not see both updates, you may rename function names and bump numbers being part of function names (eg. 9003 => 9005 and 9004 to 9006).

    Please let me know if it helped.

  • πŸ‡ΊπŸ‡ΈUnited States djmymy

    Hi @jsobiecki,
    I did these steps.

    1. Because the module in Drupal project is missing the .install file I did a 'git clone https://git.drupalcode.org/project/translatable_menu_link_uri.git' inside the contrib module folder.

    2. I then cd inside the translatable menu link folder and ran this command:

    git fetch "https://git.drupalcode.org/issue/translatable_menu_link_uri-3259442.git" '3259442-notice-undefined-index'
    git checkout -b 'translatable_menu_link_uri-3259442-3259442-notice-undefined-index' FETCH_HEAD

    3. I noticed the change with the updates you did on the .install so I ran 'drush updb'

    4. Now I got this:

    drush updb
     --------------- ----------- --------------- --------------------------------
      Module          Update ID   Type            Description
     --------------- ----------- --------------- --------------------------------
      translatable_   9002        hook_update_n   9002 - Make sure that database
      menu_link_uri                               and entities definition are in
                                                  sync.
      translatable_   9003        hook_update_n   9003 -
      menu_link_uri
     --------------- ----------- --------------- --------------------------------
    
    
     Do you wish to run the specified pending updates? (yes/no) [yes]:
     > yes
    
    >  [notice] Update started: translatable_menu_link_uri_update_9002
    >  [notice] Update completed: translatable_menu_link_uri_update_9002
    >  [notice] Update started: translatable_menu_link_uri_update_9003
    >  [error]  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mlcd.link_override__options' in 'field list': SELECT "mlcd"."id" AS "id", "mlcd"."link__options" AS "link__options", "mlcd"."link_override__options" AS "link_override__options"
    > FROM
    > "menu_link_content_field_revision" "mlcd"; Array
    > (
    > )
    >
    >  [error]  Update failed: translatable_menu_link_uri_update_9003
     [error]  Update aborted by: translatable_menu_link_uri_update_9003
     [error]  Finished performing updates.
  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    Hi @djmymy,

    Thanks for checking. It's weird, as I'm not able to reproduce this problem. I checked 9.x and 10.x Drupal versions. My scenario:

    1. Install Umami profile as bootstrap.
    2. Install old (1.x) version of translatable_menu_link
    3. Configure module as described in project description.
    4. Create couple menu links.
    5. Switch to translatable_menu_link_uri-3259442-3259442-notice-undefined-index
    6. drush updatedb:

    The following updates are pending:
    
    translatable_menu_link_uri module : 
      9002 - Make sure that database and entities definition are in sync.
      9003 - 
    
    Do you wish to run all pending updates? (y/n): y
    Performing translatable_menu_link_uri_update_9002                                                                  [ok]
    Performing translatable_menu_link_uri_update_9003                                                                  [ok]
    Cache rebuild complete.                               

    So I have couple of questions:
    - What Drupal core version you use?
    - Could you reproduce my steps?

  • πŸ‡§πŸ‡¬Bulgaria rastepanyan

    Hi @jsobiecki and @djmymy,

    I could confirm that I have the same issue as @djmymy after applying the drush updb command:

    wodby@php.container:/var/www/html/docroot $ drush updb
     ---------------------------- ----------- --------------- ------------------------------------------------------------------------ 
      Module                       Update ID   Type            Description                                                             
     ---------------------------- ----------- --------------- ------------------------------------------------------------------------ 
      translatable_menu_link_uri   9003        hook_update_n   9003 - Set the overridden link options to the same as the parent link.  
     ---------------------------- ----------- --------------- ------------------------------------------------------------------------ 
    
     Do you wish to run the specified pending updates? (yes/no) [yes]:
     > y
    
    >  [notice] Update started: translatable_menu_link_uri_update_9003
    >  [error]  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mlcd.link_override__options' in 'field list': SELECT "mlcd"."id" AS "id", "mlcd"."link__options" AS "link__options", "mlcd"."link_override__options" AS "link_override__options"
    > FROM
    > "menu_link_content_field_revision" "mlcd"; Array
    > (
    > )
    >  
    >  [error]  Update failed: translatable_menu_link_uri_update_9003 
     [error]  Update aborted by: translatable_menu_link_uri_update_9003 
     [error]  Finished performing updates. 

    The Drupal Core is 9.3.22, the PHP version is 7.4
    I'm using the 2.x-dev version of the module.

  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    @rastepanyan Please apply changes from MR provided in https://git.drupalcode.org/project/translatable_menu_link_uri/-/merge_re... and try again.

  • πŸ‡§πŸ‡¬Bulgaria rastepanyan

    Hi @jsobiecki,

    I have already applied the changes from the provided MR, and the issue with drush updb command from #17 is with it. Without changes I just got the notice from the title:

    Notice: Undefined index: link_override__uri in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromSharedTables() (line 602 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    Hi @rastepanyan,

    I believe there is small misunderstanding. The patch I linked above (https://git.drupalcode.org/project/translatable_menu_link_uri/-/merge_re...) changes translatable_menu_link_uri_update_9003 function and adds translatable_menu_link_uri_update_9004 function. 9003 make sure that new structure is used, and 9004 is generaly what old 9003 was.

    If after applying patch you see only one (9004) update, please do following thing: (Drupal >= 9.3)
    drush ev "\Drupal::service('update.update_hook_registry')->setInstalledVersion('translatable_menu_link_uri', 9002);"

    this will allow you to re-execute update.

  • πŸ‡§πŸ‡¬Bulgaria rastepanyan

    Hi @jsobiecki,

    Thank you for your help! I have used the proposed solution and now have two update available - 9002 and 9003. When I ran `drush updb` command the update 9002 was applied successfully, but the 9003 failed again:

    wodby@php.container:/var/www/html/docroot $ drush updb
     ---------------------------- ----------- --------------- ------------------------------------------------------------------------ 
      Module                       Update ID   Type            Description                                                             
     ---------------------------- ----------- --------------- ------------------------------------------------------------------------ 
      translatable_menu_link_uri   9002        hook_update_n   9002 - Make sure that database and entities definition are in sync.     
      translatable_menu_link_uri   9003        hook_update_n   9003 - Set the overridden link options to the same as the parent link.  
     ---------------------------- ----------- --------------- ------------------------------------------------------------------------ 
    
    
     Do you wish to run the specified pending updates? (yes/no) [yes]:
     > y
    
    >  [notice] Update started: translatable_menu_link_uri_update_9002
    >  [notice] Update completed: translatable_menu_link_uri_update_9002
    >  [notice] Update started: translatable_menu_link_uri_update_9003
    >  [error]  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mlcd.link_override__options' in 'field list': SELECT "mlcd"."id" AS "id", "mlcd"."link__options" AS "link__options", "mlcd"."link_override__options" AS "link_override__options"
    > FROM
    > "menu_link_content_field_revision" "mlcd"; Array
    > (
    > )
    >  
    >  [error]  Update failed: translatable_menu_link_uri_update_9003 
     [error]  Update aborted by: translatable_menu_link_uri_update_9003 
     [error]  Finished performing updates. 
    
  • πŸ‡ΊπŸ‡ΈUnited States djmymy

    Hi guys,
    So my coworker noticed field columns were not created on the database when we updated version 2.x: link_override__uri, link_override__title, and link_override__options. So he created a simple custom module and added this. Once those tables were created, everything worked.

    function custom_entity_update_update_9010() {
        $link_override__uri = [
          'type' => 'varchar',
           'length' => 255,
           'not null' => FALSE,
           'default' => ''
           ];
        $link_override__title = [
           'type' => 'varchar',
           'length' => 255,
           'not null' => FALSE,
           'default' => ''
           ];
        $link_override__options = [
           'type' => 'blob',
           'size' => 'big',
           'not null' => FALSE
           ];
        $database = \Drupal::database();
        $schema = $database->schema();
    
        $schema->addField('menu_link_content_field_revision', 'link_override__uri', $link_override__uri);
        $schema->addField('menu_link_content_field_revision', 'link_override__title', $link_override__title);
        $schema->addField('menu_link_content_field_revision', 'link_override__options', $link_override__options);
    }
    
  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    Hi rastepanyan, djmymy,

    Could you provide me your execution context (What version of Drupal core, PHP, and MySQL). It seems that update 9002 wasn't able to update database schema for you. On my end, it worked as expected.

    @djmymy,

    Thanks for proposal, but I don't think it's walid way to handle entity schema updates. Please review hook 9002 from merge request: https://git.drupalcode.org/project/translatable_menu_link_uri/-/merge_re...

    Maybe there is something missing there, after getting full context from you, I'll take a second glance on it.

  • πŸ‡§πŸ‡¬Bulgaria rastepanyan

    Hi @jsobiecki,

    The Drupal Core is 9.3.22, the PHP version is 7.4.33 and the MySQL version on the server is 5.7.40-43 (I'm using MariaDB v10.3.28 locally).

  • πŸ‡ΊπŸ‡ΈUnited States djmymy

    Hi jsobiecki,

    So we noticed that when we updated from 1.x to 2.x during our migration from Drupal 8.x to 9.x, it didn't create those columns in the database. So I tried it again without forcing the creation of the columns and merged your request, and I got this. Here's our spec

    Drupal 9.5.3, PHP 8.0.13, MySQL 5.7.36

    drush updb
     -------------- ----------- --------------- -----------------------------------
      Module         Update ID   Type            Description
     -------------- ----------- --------------- -----------------------------------
      translatable   9002        hook_update_n   9002 - Make sure that database
      _menu_link_u                               and entities definition are in
      ri                                         sync.
      translatable   9003        hook_update_n   9003 - Set the overridden link
      _menu_link_u                               options to the same as the parent
      ri                                         link.
     -------------- ----------- --------------- -----------------------------------
    
    
     Do you wish to run the specified pending updates? (yes/no) [yes]:
     > yes
    
    >  [notice] Update started: translatable_menu_link_uri_update_9002
    >  [notice] Update completed: translatable_menu_link_uri_update_9002
    >  [notice] Update started: translatable_menu_link_uri_update_9003
    >  [error]  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mlcd.link_override__options' in 'field list': SELECT "mlcd"."id" AS "id", "mlcd"."link__options" AS "link__options", "mlcd"."link_override__options" AS "link_override__options"
    > FROM
    > "menu_link_content_field_revision" "mlcd"; Array
    > (
    > )
    >
    >  [error]  Update failed: translatable_menu_link_uri_update_9003
     [error]  Update aborted by: translatable_menu_link_uri_update_9003
     [error]  Finished performing updates.
  • πŸ‡·πŸ‡ΈSerbia botanic_spark

    I am also getting the same errors after running db update

  • πŸ‡ΊπŸ‡ΈUnited States inversed

    I am getting the errors after installing 2.0 and have never had 1.0 installed. I cannot successfully apply the patch from the MR, though.

    This is on Drupal 9.5.3, PHP 8.1.x, and MariaDB 10.4.

  • First commit to issue fork.
  • @angrytoast opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States angrytoast Princeton, NJ

    We tested out the latest changes in MR4 and see the same issues with Column not found: 1054 Unknown column 'mlcd.link_override__options' in menu_link_content_field_revision.

    This is with:

    • Drupal 9.5.8
    • PHP 8.1.14
    • MariaDB 10.4.27
    • Started using translatable_menu_link_uri at 1.2.0, updated to 2.0.0, and now trying to update to latest 2.x-dev commit dev-2.x#822d9712

    I looked through the issue queue a bit and found https://www.drupal.org/project/translatable_menu_link_uri/issues/3221161... πŸ› Mismatched entity and/or field definitions RTBC which contained an update hook example that worked. It looks like it should be used in place of some of the changes here. I've opened https://git.drupalcode.org/project/translatable_menu_link_uri/-/merge_re... which I could run with no issues.

    I've also tested resetting the schema version back to 8001 to re-run both and it doesn't appear to have any issues. However it'd be good for others who have already ran 8001 to see if there are issues.

  • πŸ‡§πŸ‡·Brazil murilohp

    I had an specific scenario where the link_override__options did not exist on menu_link_content_field_revision table, so I've made this patch to skip the update when a field doesn't exist. I hope it helps.

  • πŸ‡ͺπŸ‡ΈSpain rcodina

    Patch on #31 fixed the issue for me.

  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    It's looks like this is a bug that haunts this module for people that tried to update from old version. I'm not able to reproduce this issue anymore, but change provided by @rcoding seems to be ok and not harmful. I'm going to merge it.

  • Status changed to Fixed 10 months ago
  • πŸ‡΅πŸ‡±Poland jsobiecki Wroclaw

    Merged last patch, hopefully it will fix old issues.

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

  • Status changed to Fixed 5 months ago
  • πŸ‡©πŸ‡ͺGermany thomaswalther Rhein-Main Area

    Worked for me, changing the file translatable_menu_link_uri.install with the patch 3259442 of:
    https://git.drupalcode.org/issue/translatable_menu_link_uri-3259442/-/bl...

    But I could not find the correction in the @dev. So I update manually:

    wget https://git.drupalcode.org/issue/translatable_menu_link_uri-3259442/-/raw/3259442-redo-update-hooks/translatable_menu_link_uri.install?inline=false
    mv 'translatable_menu_link_uri.install?inline=false' translatable_menu_link_uri.install
    mv modules/contrib/translatable_menu_link_uri/translatable_menu_link_uri.install modules/contrib/translatable_menu_link_uri/translatable_menu_link_uri.install_SAVE
    mv translatable_menu_link_uri.install modules/contrib/.
    
Production build 0.69.0 2024