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."

Command icon 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

StevenPatz created an issue. See original summary.

themodularlab’s picture

@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.

stevenpatz’s picture

Update:
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.

themodularlab’s picture

If you get a chance, please post your entire error so that we can try to figure out the source of the issue. Thanks.

maxwellkeeble’s picture

StatusFileSize
new259.38 KB

I'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.

chiefme’s picture

Same issue on multiple websites.

stevenpatz’s picture

This 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).

themodularlab’s picture

Thanks 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.

leisurman’s picture

StatusFileSize
new14.31 KB

Drupal Version 9.2.6 | tb_megamenu 8.x-1.4
I get this error

themodularlab’s picture

StatusFileSize
new2.68 KB

I 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.

themodularlab’s picture

Status: Active » Needs review
stevenpatz’s picture

I will test this in about an hour or so.

stevenpatz’s picture

Patch 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.

bmunslow’s picture

Hi 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.twig template file, which I had overriden in my custom theme, and replace every occurrence of link.title_translate with link.title_translated

Perhaps it could be documented that the name of this variable was updated in template_preprocess_tb_megamenu_item and 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

bmunslow’s picture

Hello 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

stevenpatz’s picture

I will test this in about an hour.

stevenpatz’s picture

The steps in #14 plus the patch in #10 fix my issue.

themodularlab’s picture

@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.

themodularlab’s picture

@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.

stevenpatz’s picture

Update: 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.

themodularlab’s picture

@StevenPatz is that from using the initial patch that I added or with the MR that @bmunslow posted?

baldwinlouie’s picture

Thanks all for the work on this. I added this patch to my site and it is working.

stevenpatz’s picture

@themodularlab

It occurs with both patches. I tried then editing the MM we have and it does not save. Just throws up the 'Undefined'

knaffles’s picture

The 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.

stevenpatz’s picture

Yeah 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.

themodularlab’s picture

@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.

stevenpatz’s picture

That'd be great for a new release. I am leaning towards my issue being an old problem we've had with this module before.

themodularlab’s picture

Status: Needs review » Reviewed & tested by the community

Okay. 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!

quondam’s picture

@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.

themodularlab’s picture

themodularlab’s picture

Status: Reviewed & tested by the community » Fixed
stevenpatz’s picture

Is 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.

themodularlab’s picture

@StevenPatz, Yeah let's see what we can figure out here. Can you provide some more info on your site?

such as:

  • Theme info: Parent & Sub themes?
  • Any overridden TB twig templates?
  • Any overridden preprocess functions?
  • Version of drupal
  • Version of php
  • Any other info that might help us either diagnose the issue or be able to recreate your issue.
stevenpatz’s picture

Oh 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.

themodularlab’s picture

No 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.

jegan2668’s picture

Hi @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.

themodularlab’s picture

@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.

Status: Fixed » Closed (fixed)

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