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

lilou - October 11, 2008 - 14:40
Project:API
Version:HEAD
Component:Parser
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

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

#1

Dave Reid - October 11, 2008 - 15:09
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

System Message - November 16, 2008 - 21:45
Status:needs review» needs work

The last submitted patch failed testing.

#3

Dave Reid - November 17, 2008 - 03:58
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

catch - November 22, 2008 - 23:35
Project:Drupal» API
Version:7.x-dev» HEAD
Component:documentation» Parser
Category:task» bug report
Status:needs review» needs work

Moving to api.module.

#5

Dave Reid - November 23, 2008 - 05:20
Status:needs work» needs review

This still applies. Hopefully gets retested soon.

#6

drumm - December 26, 2008 - 23:27
Status:needs review» 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.

 
 

Drupal is a registered trademark of Dries Buytaert.