Problem/Motivation

After updating the local install (ddev) to PHP 7.4 I noticed this error showing up:

Notice: Trying to access array offset on value of type int in format_string() (line 1823 of /var/www/html/includes/bootstrap.inc).

I traced it to the menu items added for 'Add discount' and 'Import discount'.

Proposed resolution

Just wrap the menu link titles in t(), don't use a title callback.

Remaining tasks

n/a

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new793 bytes

This patch completes the suggested change; after making this change the error went away.

Status: Needs review » Needs work

The last submitted patch, 2: commerce_discount-n3174880-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new580 bytes

I forgot that menu titles are translated at runtime, so shouldn't be wrapped by t() in their hook_menu definition.

Status: Needs review » Needs work

The last submitted patch, 4: commerce_discount-n3174880-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Status: Needs work » Needs review
StatusFileSize
new829 bytes

Ah, I needed to unset some things. This should work.

joelpittet’s picture

I'm not sure I understand the unsets? I understand the rest of it. Patch in #4 should have worked, no?

solideogloria’s picture

@DamienMcKenna I agree with what was said in #7. The patches work, but I don't understand why the unset lines are needed (other than that it helps a test pass?)

pontus.froden’s picture

#6 works for me.

I don't get the unsets either.

jacob.embree’s picture

Status: Needs review » Reviewed & tested by the community

The unset() calls are necessary because title callback and title arguments take precedence over title, and the parent class sets title callback to entity_ui_get_action_title() and also sets title arguments.

tonytheferg’s picture

Thanks for the patch, I am also seeing this from the links that commerce paypal creates in dblog.

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed

The fun of inheritance, just like IRL it rarely lasts past 2 generations ;) Committed to dev branch, thanks all.

Status: Fixed » Closed (fixed)

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