My question is, if deadwood already converting url() properly from 5.x to 6.x

Here is the explanation of problem:
http://drupal.org/node/362799

And issue:
#352344: Fatal error: Unsupported operand types in common.inc on line 1369

Comments

dave reid’s picture

Looks like it is:

/**
 * Convert calls to url() and l().
 *
 * See: http://drupal.org/node/114774#url.
 * Adapted from the script at http://drupal.org/files/issues/replace.php_.txt.
 *
 * @param string $file The file to convert.
 */
function deadwood_convert_url(&$file) {
  $hook = 'url';
  $msg = "/* TODO\n" .
         "   Please manually fix the parameters on the l() or url() function on the next line.\n" .
         "   Typically, this was not changed because of a function call inside an array call like\n" .
         "   array('title' => t('View user profile.'))." .
         "*/\n";

  $callbacks = array('deadwood_fix_l', 'deadwood_fix_url');
  foreach ($callbacks as $callback) {
    $cur = $file;
    $new = '';

    // Process file in chunks to avoid PCRE bug?
    $pattern = $callback == 'deadwood_fix_l' ? '/(?=(?<!ion )(?<![a-zA-Z_\'\"])l\()/' : '/(?=(?<!ion )(?<![a-zA-Z_\'\"])url\()/';
    $chunks = preg_split($pattern, $cur);

    $search = $callback == 'deadwood_fix_l' ? '@(?<!ion )(?<![a-zA-Z_\'\"])l\((([^()]*|\((?2)?\))+)\)@' : '@(?<!ion )(?<![a-zA-Z_\'\"])url\((([^()]*|\((?2)?\))+)\)@';

    foreach ($chunks as $chunk) {
      $chg = preg_replace_callback($search, $callback, $chunk);
      $new .= $chg != '' ? $chg : $msg . $chunk;
    }

    deadwood_save_changes($cur, $new, $file, $hook);
  }
}

/**
 * Callback function for converting l() references.
 *
 * @param array $matches Function arguments.
 * @return Text of converted function call.
 */
function deadwood_fix_l($matches) {
  $args = deadwwod_get_args($matches[1]);

  // Two arguments, no change.
  if (count($args) <= 2) {
    return $matches[0];
  }

  $options = "array(";
  if (isset($args[2]) && $args[2][1] != 'array()' && $args[2][1] != 'NULL') {
    $options .= "'attributes' => " . $args[2][1] . ', ';
  }
  if (isset($args[3]) && $args[3][1] != "''" && $args[3][1] != '""' && $args[3][1] != 'NULL') {
    $options .= "'query' => " . $args[3][1] . ', ';
  }
  if (isset($args[4]) && $args[4][1] != "''" && $args[4][1] != '""' && $args[4][1] != 'NULL') {
    $options .= "'fragment' => " . $args[4][1] . ', ';
  }
  if (isset($args[5]) && $args[5][1] != "FALSE") {
    $options .= "'absolute' => TRUE, ";
  }
  if (isset($args[6]) && $args[6][1] != "FALSE") {
    $options .= "'html' => TRUE, ";
  }
  $options = rtrim($options, ', ');

  $return = 'l('. $args[0][1] . ', ' . $args[1][1] . ', ' . $options  . '))';
  return $return;
}

But I haven't tried it myself, so I'm leaving the status as-is.

kenorb’s picture

Because many converted modules die on core 6.x, so to make sure:)
But I'm not sure if people were using deadwood for it.

solotandem’s picture

Assigned: Unassigned » solotandem
Status: Postponed (maintainer needs more info) » Fixed

As Dave points out, Deadwood utilizes a function that was written explicitly for the url() and l() fixes. In my testing I have not seen the converted code fail to run under D6. If you have a specific situation where it fails, please submit a new issue. I will mark this fixed for now.

Status: Fixed » Closed (fixed)

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