The l() function has changed in some aspects from D6 -> D7, but it more or less still looks the same and is used the same we just ran into this error when building a site:

Fatal error: [] operator not supported for strings in /.../includes/common.inc on line 2277

basically what happened was that the developer was using the old way of adding classes to a link: $link['attributes'] = array('class' => 'myclass'). However, 'class' now needs to be an array.

There's already a comment on that api page (http://api.drupal.org/api/drupal/includes--common.inc/function/l/7) about classes being arrays, but I think it makes sense to have it as part of the official documentation since I imagine a lot of people will probably be running into this identical error when they upgrade their modules and themes to D7.

This patch just adds a one-line change to the api documentation for the l() function.

CommentFileSizeAuthor
#4 972918.patch973 bytesjhodgdon
l_api_class.patch554 byteshadsie
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, l_api_class.patch, failed testing.

arianek’s picture

hey scott i am no patch pro after not doing any for many months, but i think maybe it's missing a few lines at the top (before the line starting with diff) that usually look like:

Index: themes/garland/style.css
=====================================================
RCS file: /cvs/drupal/drupal/themes/garland/style.css,v
retrieving revision 1.53

maybe the git thing you were trying out is losing those?

altrugon’s picture

Subscribe.

jhodgdon’s picture

Status: Needs work » Needs review
FileSize
973 bytes

Good idea...

The patch is not the right way to do it though (besides being formatted incorrectly). I think what we should do is this instead (easier to explain via a patch than in a sentence).

hadsie’s picture

Thanks @jhodgdon, I like yours a lot better :)

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

joachim’s picture

This also needs a mention in the 6-7 conversion docs page. (Which looks far too complicated for me to even think about editing before breakfast :(

webchick’s picture

Category: feature » task
Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks!

jhodgdon’s picture

Status: Fixed » Needs work

Setting back to "needs work" because (as joachim says in #7) it probably needs documenting on the (totally huge, totally out of date) module update page.

jhodgdon’s picture

Issue tags: +Needs documentation

Adding the Needs Doc tag because that's how we tag for the API update page

jhodgdon’s picture

Version: 7.0-beta2 » 7.x-dev
Issue tags: -Needs documentation +Needs documentation updates

Changing tag and version. New tag "Needs update documentation" is for issues that need doc on the update page.

dale42’s picture

Assigned: Unassigned » dale42

Working on for doc sprint

dale42’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Fixed

Looks good to me, thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Needs documentation updates

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