Hi guys,

The list() in the following code snippet generates an E_NOTICE error whenever $original_title does not include a pipe (|) character. It is annoying...

    [...]
    list($title, $title_attr) = explode("|", $original_title, 2);
    if (isset($title_attr)) {
    [...]

You can simply use the @ sign to remove the E_NOTICE. (although that removes all the notices: the list() and the explode() notices are hidden.)

Otherwise, you'd have to explode to an array and check the array appropriately (i.e. isset($my_array[1]) to know whether there are attributes.)

Thank you.
Alexis Wilke

CommentFileSizeAuthor
#2 1020808_cb_list_patch.diff2.46 KBMGN

Comments

MGN’s picture

Yes, but I have also read it can be inefficient to ignore notice messages in this way (and can hide other errors as you mentioned) .

I suppose the best way is to do it in two steps as you describe.

MGN’s picture

Status: Active » Needs review
StatusFileSize
new2.46 KB

Here is a patch that eliminates list in custom_breadcrumbs.module, hopefully fixing the E_NOTICE problem.

AlexisWilke’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, I don't get the E_NOTICEs anymore.

Thank you.
Alexis

toodlepip’s picture

Lovely, thank you, that did the job nicely.

MGN’s picture

Status: Reviewed & tested by the community » Fixed

Thanks. This has now been committed to 6.x-2.x-dev.

Status: Fixed » Closed (fixed)

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