Download & Extend

$user is display twice in globals page (api.drupal.org)

Project:API
Version:master
Component:Parser
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (duplicate)

Issue Summary

See : http://api.drupal.org/api/globals/7

Comments

#1

Status:active» needs review

Weird. The line that was picked up is in modules/php/php.module:

<?php
        $output
.= '<li>' . t('<p>To display the name of a registered user, use this instead:</p>
<pre>
global $user;
if ($user->uid) {
  print t(\'Welcome @name! Thank you for visiting.\', array(\'@name\' => $user->name));
}
else {
  print t(\'Welcome visitor! Thank you for visiting.\');
}
</pre>'
) . '</li></ul>';
?>

Is this a bug that can be easily fixed in the API module? I'm not sure. Here's a patch that should fix this within the PHP module. The output is exactly the same, but it changes the string to use a surrounding double quote, so we can escape the $ characters in the example.

AttachmentSize
globals-user-319978-D7.patch 1.47 KB

#2

Status:needs review» needs work

The last submitted patch failed testing.

#3

Status:needs work» needs review

Failed due to #74645: modify file_scan_directory to include a regex for the nomask.. Setting back to code needs review.

#4

Project:Drupal core» API
Version:7.x-dev» master
Component:documentation» Parser
Category:task» bug report
Status:needs review» needs work

Moving to api.module.

#5

Status:needs work» needs review

This still applies. Hopefully gets retested soon.

#6

Status:needs review» closed (duplicate)

This caused by API's regular-expression-powered PHP parser, which does not know enough about PHP syntax. The issue for that is #300031: Rework PHP parser.