Problem/Motivation
Updated today in light of the security issues, from 8.x-1.0-beta2 and the entire site, throws a white screen. I can't even log in. Doing a drush ws shows this in the logs:
InvalidArgumentException: "$string ("") must be a string."
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | issue-3238650-10.diff | 2.68 KB | themodularlab |
| #9 | error.txt | 14.31 KB | leisurman |
Issue fork tb_megamenu-3238650
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
themodularlab@StevenPatz Sorry that you are encountering some issues. Can you post the entire error message? That might help us figure out what's going on. I would also ask if you've done the usual things like clearing drupal cache, etc. There have been quite a few changes from the 2nd beta to 8.4.
Comment #3
stevenpatzUpdate:
I have tried going from 1.1 to 1.2 to 1.3 in my composer.json, running drush updb after each and the site works fine. I then change the composer to 1.4, and update, drush updb, drush cr and I get the original error.
Comment #4
themodularlabIf you get a chance, please post your entire error so that we can try to figure out the source of the issue. Thanks.
Comment #5
maxwellkeeble commentedI'm experiencing the same issue. I've attached a full error log.
The main ones are:
Notice: Undefined index: submenu_config in Drupal\tb_megamenu\Entity\MegaMenuConfig->getMenuConfig() (line 157 of modules/contrib/tb_megamenu/src/Entity/MegaMenuConfig.php).
Notice: Trying to access array offset on value of type null in Drupal\tb_megamenu\Entity\MegaMenuConfig->getMenuConfig() (line 157 of modules/contrib/tb_megamenu/src/Entity/MegaMenuConfig.php).
Notice: Undefined index: item_config in Drupal\tb_megamenu\Entity\MegaMenuConfig->getMenuConfig() (line 158 of modules/contrib/tb_megamenu/src/Entity/MegaMenuConfig.php).
Notice: Trying to access array offset on value of type null in Drupal\tb_megamenu\Entity\MegaMenuConfig->getMenuConfig() (line 159 of modules/contrib/tb_megamenu/src/Entity/MegaMenuConfig.php).
And so on.
Comment #6
chiefme commentedSame issue on multiple websites.
Comment #7
stevenpatzThis is the full error
InvalidArgumentException: $string ("") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct() (line 132 of /var/application/docroot/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php).Comment #8
themodularlabThanks everyone for the more detailed error messages. This is definitely related to the security fixes we released yesterday. I'll take a look at this and try to resolve ASAP.
Comment #9
leisurman commentedDrupal Version 9.2.6 | tb_megamenu 8.x-1.4
I get this error
Comment #10
themodularlabI have included a patch, that I believe addresses the issues here as well as separate issues related to html characters (such as & vs &) being removed/converted as well as issue with menu titles.
Comment #11
themodularlabComment #12
stevenpatzI will test this in about an hour or so.
Comment #13
stevenpatzPatch applied with a bit of fuzz. I ran a drush cr and refreshed the page and still had the white screen, logged in on another tab and the admin for the TB seems okay. Tried to log in from a second tag and got the same white screen. drush ws shows the same error I reported earlier.
Comment #14
bmunslow commentedHi everyone,
Patch in #10 fixes the issue, but please note the following adjustments are needed:
In the first place, I had to go to
/admin/structure/tb-megamenu, edit my mega menu, and press the Save button in the MegaMenu Toolbox. After doing this, the Undefined index: label in template_preprocess_tb_megamenu_item() errors where gone, and the TB Mega Menu Simulator was fully functional again.However, I was still getting the error InvalidArgumentException: $string ("") must be a string in the frontend.
In order to fix it, I had to edit the
tb-megamenu-item.html.twigtemplate file, which I had overriden in my custom theme, and replace every occurrence oflink.title_translatewithlink.title_translatedPerhaps it could be documented that the name of this variable was updated in
template_preprocess_tb_megamenu_itemand that it must be updated if custom twig template files are being used.After these steps, my site is fully functional (and secure) with latest version 8.x-1.4
Comment #16
bmunslow commentedHello again,
I was able to further investigate this issue and noticed that, despite the patch, when creating a new Tb Mega Menu, the Undefined index: label in template_preprocess_tb_megamenu_item() error was shown again, although it disappears after editing the Tb Mega Menu and pressing the Save button on the MegaMenu toolbox.
I've gone ahead an opened a MR which fixes this issue as well, by providing a default empty value for the label attribute. Please note this MR includes patch in #10 as well, so it should be a complete fix for the problem.
This is the full patch:
https://git.drupalcode.org/project/tb_megamenu/-/merge_requests/47.patch
Comment #17
stevenpatzI will test this in about an hour.
Comment #18
stevenpatzThe steps in #14 plus the patch in #10 fix my issue.
Comment #19
themodularlab@bmunslow Awesome! Thanks for testing and expanding on it. I really appreciate everyone reporting / contributing to this so that we can resolve this quickly. I'll pull down this branch and test as well. I would definitely like to get this released asap.
Comment #20
themodularlab@bmunslow This looks great and does appear to solve all the issues. We will add some notes to the release about needing to check any overridden values in twig as well as preprocess functions. Also I think the link.title_translate vs link.title_translated was a mistake on my part. We should probably revert that variable name back to its original name in order to cut down on issues like the one you encountered. Do you want to update your PR with that? otherwise, I can make that update separately.
Comment #21
stevenpatzUpdate: The patch allows the existing menu to load and the site is fine. BUT. When I go to edit the Megamenu, and save I just get a popup that says 'Undefined'. Nothing in the error logs.
Comment #22
themodularlab@StevenPatz is that from using the initial patch that I added or with the MR that @bmunslow posted?
Comment #23
baldwinlouie commentedThanks all for the work on this. I added this patch to my site and it is working.
Comment #24
stevenpatz@themodularlab
It occurs with both patches. I tried then editing the MM we have and it does not save. Just throws up the 'Undefined'
Comment #25
knaffles commentedThe patch is working for me as well. @StevenPatz, just a sanity check -- did you clear caches after updating? I know there were some other updates in this release that would require a cache clear...maybe that's interfering with your save action.
Comment #26
stevenpatzYeah drupal cr is a standard command I run almost in my sleep :) I am dogging into this locally, as we really need to get our site updated, hoping to have a better idea soon.
Comment #27
themodularlab@StevenPatz We figured you had but still figured it was worth asking :)
We're going to test this a little more, but I think we'll look to do a new release this afternoon and try to address your issue separately if it is still a problem.
Comment #28
stevenpatzThat'd be great for a new release. I am leaning towards my issue being an old problem we've had with this module before.
Comment #30
themodularlabOkay. I think this is good to go. Release coming up shortly. @StevenPatz, if you or anyone else is encountering the remaining issue, feel free to reopen this issue or create a new one and we'll continue to investigate. I feel good enough about the other fixes to proceed with a release. Thanks to everyone to reported, confirmed the issue, created patches, testing, etc. I appreciate you all. The drupal community is the best!
Comment #31
quondam commented@themodluarlab per our conversation this afternoon I updated my local environment to 8.x-1.4 and was able to reproduce the original issue immeditely, seeing the error from #7 in my logs.
Applied your patch from #10 then followed the notes from @bmunslow in #14 - which led me to what I'm guessing is the same conclusion they ultimately had: when the TB config object was modified in the process of addressing the recent security advisories, the tb_megamenu.module file was also updated to assume the existence of a label attribute (see line 615 here).
Without the patch from #16 in place all existing sites with (outdated) config objects predating the 8.x-1.4 release will throw an error due to the newly added label attribute. @bmunslow's patch sucessfully addresses that; an additional (but arguably unnecessary) safeguard to protect sites until they re-save the TB config object would be to wrap line 615 in the link above with a conditional checking for the existence of that label attribute.
I haven't been able to reproduce the issue from #21 but suspect it could be due to an outdated config object - recall we'd made some pretty major changes to how that was stored, specifically here.
Comment #32
themodularlabComment #33
themodularlabComment #34
stevenpatzIs there something beyond drush cr, I need to do to get this to work? Locally and if I am already logged in on a test environment it works fine. But if someone else tries to visit the site, the
InvalidArgumentException: $string ("") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct() (line 132 of /var/application/docroot/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php).is back in the logs.
I have double checked and the version is 1.5. Any help apprecriated.
Comment #35
themodularlab@StevenPatz, Yeah let's see what we can figure out here. Can you provide some more info on your site?
such as:
Comment #36
stevenpatzOh I see I need to revert the changes we did in the custom twig file in the middle of testing the original patch. Disregard previous comment.
Comment #37
themodularlabNo worries! Hopefully that addresses the issue. But if not, reply back with some of the info I requested and we'll see if we can help you figure this out.
Comment #38
jegan2668 commentedHi @themodularlab,
Always, the first tb_megamenu was working fine. But the second tb_megamenu in same page has issue, that doesn't load the child menu items.
Notice: Trying to get property 'link' of non-object in template_preprocess_tb_megamenu_subnav() (line 271 of /app/docroot/modules/contrib/tb_megamenu/tb_megamenu.module).
Used the latest version of this module 8.x-1.5, which contains all the patches.
Comment #39
themodularlab@Jegan2668. Thanks this info is helpful. I don't recall anyone previously reporting any errors related to the
template_preprocess_tb_megamenu_subnav()so that's a new place for us to investigate.