In filefield_paths.module, with transliteration module installed:

/**
 * Process and cleanup strings.
 */
function filefield_paths_process_string($value, $data, $settings = array()) {
 ...

  // Transliterate string.
  if (module_exists('transliteration') && isset($settings['transliterate']) && $settings['transliterate']) {
    $value = transliteration_get($value);
    if ($type == 'field') {
      $paths = explode('/', $value);
      foreach ($paths as &$path) {
        $path = transliteration_clean_filename($path);
      }

      $value = implode('/', $paths);
    }
  }

...
}

$type is not defined, I can't figure out what its supposed to be.

Comments

vitok-dupe’s picture

same problem.
subscribe.

pglatz’s picture

Same problem - line 599

chriz001’s picture

subscribe

mooselimb’s picture

Same here. Has there been a fix in the intervening period?
When uploading image (I guess it'll be the same with any file) I get:

Notice: Undefined variable: type in filefield_paths_process_string() (line 598 of site-directory/sites/all/modules/filefield_paths/filefield_paths.module)

Disabling Transliteration in the file name & file path settings stops the error.

Admin > Structure > Content types > Image > edit > image settings > Image Path settings > FILE NAME cleanup settings
&
Admin > Structure > Content types > Image > edit > image settings > Image Path settings > FILE PATH cleanup settings

Does this mean it's a Transliteration prob?
I'm using FileField Paths 7.x-1.x-dev & Transliteration 7.x-3.0-alpha1

Barfly’s picture

hello ,
same problem i got : Notice: Undefined variable: type in filefield_paths_process_string() (line 600 of C:\...\modules\filefield_paths\filefield_paths.module

metakel’s picture

I have the same error and with the same line number. And I notice that the module does not have effect on transliterating the uploaded file paths of removing spaces.

e.g. I'd set the uploaded file path of an image field to: images/[node:title], with all "Cleanup using Pathauto", "Convert to lower case", "Transliterate File path" selected.

Then when the node title is "Firstname Lastname", the file should be placed at: "images/firstname-lastname". But it turns out to be put at: "images/firstname lastname". Note that the space is not removed.

I wonder whether this is related to the above error of "Undefined variable".

johnv’s picture

Subscribe, other line number (with latest = FileField Paths 7.x-1.x-dev (2011-Feb-25)):
Notice: Undefined variable: type in filefield_paths_process_string() (line 610 of .../filefield_paths.module).
It seems like a D6->D7 porting error.
This is a porting error: maintainer has removed the $type-argument in function filefield_paths_process_string(), because the calling logic has been changed.
Following the symptom in #6, I suggest removing the line in filefield_paths.module:
if ($type == 'field') {

ansorg’s picture

re #7: removing just this line does not make any sense because this would break the code completely.

One could remove the whole if () {..} block but then this part of the function does nothing and makes no sense anymore.

Like the OP, I don't understand what this $type could be and have no idea how to fix this.

Subscribe

jeffwidman’s picture

subscribe

sachbearbeiter’s picture

Notice: Undefined variable: type in filefield_paths_process_string() (line 598 of /xxx/filefield_paths/filefield_paths.module).

subscribe - same problem ...

tommychris’s picture

subscribe

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new794 bytes

Here's a patch that seems to fix it (needs testing).

I simply removed the if statement (but not the code in the if statement) after looking at version 6 of this module and working out that it probably just got left over in the upgrade (as johnv suggested in #7 above).

This gets rid of the errors for me, but others should test to make sure it has no adverse effects.

h0tw1r3’s picture

Title: Problem with transliteration, $type undefined » Problem in filefield_paths_process_string - transliteration $type undefined and pathauto support
StatusFileSize
new2.73 KB

Problems with current function:
1. Original reported issue, notice error $type is undefined, stems from 6 -> 7 api changes.
2. Entire path is normalized instead of the individual tokens. Problem arises when the non-token portions in the value set by an admin will be unexpectedly changed by transliterate, pathauto, or lower.
3. Pathauto is not implemented

Patch refactors filefield_paths_process_string, breaking out the individual cleaners (transliterate, pathauto, lower) to a callback function.

metakel’s picture

same Notice at line 555.

I'd tried the patch file of #13 but

patching file b/filefield_paths/filefield_paths.module
Hunk #1 FAILED at 546.
Hunk #2 FAILED at 575.
2 out of 2 hunks FAILED -- saving rejects to file b/filefield_paths/filefield_paths.module.rej

I'm using 7.x-1.x-dev

h0tw1r3’s picture

If you are in the filefield_paths directory use: patch -p2 < filefield_paths-cleanup_string.patch

metakel’s picture

thank you, I'd used -p0. Now with -p2 I patched successfully.

metakel’s picture

oh, after patched with #13, I've got this:

Fatal error: Call to undefined function transliterate_clean_filename() in /var/www/dev/d7/sites/all/modules/filefield_paths/filefield_paths.module on line 574

filefield_path.module around line 574 is listed below:

568     /**
569      * Callback for processing result of token_replace by token
570     */
571     function filefield_paths_process_callback(&$replacements, &$data, &$options) {
572       foreach ($replacements as &$value) {
573         if ($options['callback_options']['transliterate']) {
574           $value = transliterate_clean_filename($value);
575         }
576         if ($options['callback_options']['pathauto']) {
577           $value = pathauto_cleanstring($value);
578         }
579         if ($options['callback_options']['lower']) {
580           $value = drupal_strtolower($value);
581         }
582       }
583     }
h0tw1r3’s picture

StatusFileSize
new2.73 KB

Fixed, and tested with transliteration module.

metakel’s picture

thank you very much! After patched the #18's file with the 7.x-1.x-dev, the notice becomes:

Notice: Undefined index: extension in filefield_paths_tokens() (line 531 of /var/www/xxx/sites/all/modules/filefield_paths/filefield_paths.module).
Notice: Undefined index: extension in filefield_paths_tokens() (line 536 of /var/www/xxx/sites/all/modules/filefield_paths/filefield_paths.module).
h0tw1r3’s picture

Am I correct in assuming you have files without extensions (no .jpg, .txt, .png, etc)? Extensions are required with the File and Image fields. Not sure how this is happening. Either way, it's a separate issue. If you have more detail (file name, origname, field definition, etc), please open a new issue.

metakel’s picture

All my files have either .png or .jpg extensions. Thank you for your advice.

h0tw1r3’s picture

Status: Needs review » Fixed

Fix applied to 7.x-1.x-dev in commit 367ccd0.

metakel’s picture

I have just replaced the filefield_paths.module by #22's. The below error is still displayed when I tried to save a content.

Notice: Undefined index: extension in filefield_paths_tokens() (line 531 of /var/www/xxx/sites/all/modules/filefield_paths/filefield_paths.module).
Notice: Undefined index: extension in filefield_paths_tokens() (line 536 of /var/www/xxx/sites/all/modules/filefield_paths/filefield_paths.module).

The content type which I wished to save has the following field type: Dateime, image, term reference, text and node reference. It has "Multilingual support" set to "Enabled, with translation".

In all my content fields (with file storage function), all the below three were selected (boxes checked) in both FILE PATH CLEANUP SETTINGS" and FILE NAME CLEANUP SETTINGS

  • Cleanup using Pathauto.
  • Convert to lower case..
  • Transliterate.

File path token were all set to event/[node:nid]
File name token were all set to [file:ffp-name-only-original].[file:ffp-extension-original] <= the default one

h0tw1r3’s picture

metakel, please open a new issue and include details for reproducing the problem. I would also suggest upgrading to the latest dev release.

Status: Fixed » Closed (fixed)

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

Deciphered’s picture

Status: Closed (fixed) » Active

Re-opening, the patch that was committed for this issue is not correct, it's applies the cleanup only to the tokens, not to anything else.

While I acknowledge that if a user was to use plain text in their replacement pattern and then set cleanup to set it to lower case, they are silly indeed, but I would still expect the plain text elements of the replacement pattern to be processed.

Deciphered’s picture

Status: Active » Fixed

Reverted to patch by BWPanda in latest dev.

Status: Fixed » Closed (fixed)

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