I get this error when I view a node.

/**

* Implements hook_comment().

*/

function file_aliases_comment($a1, $op) {

if ($op == 'view') {

$node = node_load($a1->nid);

$a1->type = $node->type;

if (($ffp = filefield_paths_get_fields($a1, $op)) == FALSE) {

**********************line 17
break;

**********************line 17
}

I changed this to...
**********************line 17
return false;
**********************line 17

...and its working fine so far. Not to familiar with php programming, but was the break; suppose to return from the funtion with a default value of false or continue executing the rest of the code?

CommentFileSizeAuthor
#4 comment_upload.inc_.patch299 byteslpalgarvio

Comments

ylavi’s picture

I experienced this too and the fix above solved my problem.

From my perspective the issue should be defined as follows:
I get this error when I view a node which has comments.
(Nodes without comments displayed OK)

lpalgarvio’s picture

Status: Patch (to be ported) » Active
Issue tags: -CCK, -FileField, -bug fix, -file aliases, -comment upload

@ #1 incorrect

this happens when you add comments or view comments in a node that has a file or more with FileField, even if File Aliases / File Paths aren't configured.

the way to reproduce the bug:
- enable CCK, FileField, File Aliases, FileField Paths, Comment Upload
- add FileField field to a content type

a)
- create a node of the same content type without a file
- view the node - so far it works fine...
- add a comment or two
- view the node - so far it works fine...
- add a File to the node, view node - returns error :(

b)
- create a node of the same content type with a file
- view the node - so far it works fine...
- add a comment - returns error :(

Fatal error: Cannot break/continue 1 level in .../file_aliases/modules/comment_upload.inc on line 17
<?php
// $Id: comment_upload.inc,v 1.1.2.1 2010/01/07 08:59:05 deciphered Exp $
/**
 * @file
 * Contains Comment Upload module integration for the File Aliases module.
 */

/**
 * Implements hook_comment().
 */
function file_aliases_comment($a1, $op) {
  if ($op == 'view') {
    $node = node_load($a1->nid);
    $a1->type = $node->type;

    if (($ffp = filefield_paths_get_fields($a1, $op)) == FALSE) {
      break;
    }

    foreach ($ffp['#files'] as &$file) {
      if ($ffp['#settings'][$file['name']]['filealias']['display'] == TRUE) {
        $filefield_paths_alias = 'filefield_paths/alias/' . $file['field']['fid'];
        if (($alias = drupal_get_path_alias($filefield_paths_alias)) != $filefield_paths_alias) {
          $a1->comment = str_replace($file['field']['filepath'], $alias, $a1->comment);
        }
      }
    }
  }
}
lpalgarvio’s picture

Status: Active » Reviewed & tested by the community

changing line 17 to return false; as suggested above WORKS FINE

    if (($ffp = filefield_paths_get_fields($a1, $op)) == FALSE) {
      return false;
    }

please review & patch

lpalgarvio’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +CCK, +FileField, +bug fix, +file aliases, +comment upload
StatusFileSize
new299 bytes

patch for File Aliases 6.x-1.1, unix unified format

Vc Developer’s picture

Status: Active » Patch (to be ported)
Issue tags: +CCK, +FileField, +bug fix, +file aliases, +comment upload

Kewl! Excellent job!

kinosura’s picture

Vc Developer, thank you for your help!

Vc Developer’s picture

@kinosura - Your welcome! :)

deciphered’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (won't fix)

The Drupal 6 version of this module will not be receiving any more support.