API page: http://api.drupal.org/api/drupal/includes--token.inc/function/token_find...

Describe the problem you have found:

Code example:

  $data = array(
    'author:name' => '[node:author:name]',
    'title'       => '[node:title]',
    'created'     => '[node:author:name]',
  );
  $results = token_find_with_prefix($data, 'author');
  $results == array('name' => '[node:author:name]');

Should be:

  $data = array(
    'author:name' => '[node:author:name]',
    'title'       => '[node:title]',
    'created'     => '[node:created]',
  );
  $results = token_find_with_prefix($data, 'author');
  $results == array('name' => '[node:author:name]');

Note the changed line: 'created' => '[node:author:name]', should be 'created' => '[node:created]',.

Attached patch changes token.inc to correct this. And while I was in there I changed documentation comments to conform to standards, see http://drupal.org/node/1354#functions. Most of the changes are line wraps to keep the comments within 80 columns. A few changes are to fix the tense - e.g. "Replace all tokens ... " was changed to "Replaces all tokens ...". One block was changed to use the correct list format (see http://drupal.org/node/1354#lists).

CommentFileSizeAuthor
token.inc_.doc-standards.patch8.26 KBTR
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Needs review

Forgot to tag it as needs review...

jhodgdon’s picture

Title: Documentation problem with token_find_with_prefix » token_find_with_prefix has typos, token.inc not up to doc standards
Status: Needs review » Reviewed & tested by the community

The patch looks good. In the future, it's better to make separate patches for separate issues though. We'll have to see if webchick or Dries is willing to commit a patch that does two separate things for the doc...

Meanwhile, I think it's a good patch and belongs in both d7 and d8.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

In this case, I'm comfortable accepting a bigger patch. Committed to 7.x and 8.x.

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