CivicActions is reviewing and upgrading multiple modules for use on client sites. Part of this work is a coding standards review. Attached you will find a patch based on a review with the coder module and a careful examination of the code. Thanks!

CommentFileSizeAuthor
panels_i18n_2.patch5.8 KBsamlerner

Comments

stella’s picture

There's one additional issue identified by the potx coder review that the attached patch doesn't cover:

panels/panels_mini/panels_mini.module:
 +94: The first parameter to t() should be a literal string. There should be no variables, concatenation, constants or other non-literal strings there.

The line of code in question is the 'category' line below:

    $types[$mini->name] = array(
      'title' => filter_xss_admin($mini->title),
      // For now mini panels will just use the contrib block icon.
      'icon' => 'icon_contrib_block.png',
      'path' => panels_get_path("content_types/block"),
      'description' => filter_xss_admin($mini->title),
      'category' => array(t(!empty($mini->category) ? $mini->category : 'Mini panel'), -8),
    );

The t() function is not intended for use on dynamic variables and it also means that the potx module is unable to extract this string for translation. This is why the i18nstrings module provides the tt() function, perhaps you should consider using that instead? There's a discussion on the misuse of t() at http://groups.drupal.org/node/15177 in case you're interested.

Cheers,
Stella

catch’s picture

These are all minor changes, but they look good to me, and the patch applies cleanly.

catch’s picture

Version: 6.x-2.0-alpha1 » 6.x-2.x-dev
Status: Needs review » Reviewed & tested by the community
sdboyer’s picture

Status: Reviewed & tested by the community » Fixed

Using tt() would necessitate introducing a direct dependency on i18n, which isn't an option. If there's some way around that, I'd be interested to hear.

However, that particular piece shouldn't actually be wrapped in t() in the first place, as it's user input. Highly privileged user input (if the site admin is remotely sane), but nevertheless...user input. So really, the change that needs to happen there is escaping, and changing the ternary to call t() only on the static string if the first value isn't set.

The original patch has been committed, alongside the changes I've just noted.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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