When saving a node, I get lots of this error/notice:

Notice: Undefined index: in _portable_path_field_attach_load() (line 52 of /var/www/blabla/sites/all/modules/portable_path/includes/edit.inc).
and this:
Notice: Undefined index: format in _portable_path_field_attach_load() (line 52 of /var/www/blabla/sites/all/modules/portable_path/includes/edit.inc).

The node fails to save the links I have modified.

I don't remember having this problems a few days ago.

When saving exactly the same node, I also have seen this:
Notice: Undefined index: host in _filefield_paths_replace_path() (line 292 of /var/www/blabla/sites/all/modules/filefield_paths/filefield_paths.module).
and this:
Notice: Undefined offset: 0 in _portable_path_field_attach_presave() (line 39 of /var/www/blabla/sites/all/modules/portable_path/includes/save.inc).

I am also using Clean URLS.

Comments

claudiuv’s picture

Also, in the Broken links report I see two new lines
Permission restrictions deny you access to this broken link.

Is there any recommendation for setting the Filter processing order in Content->Formats ? I am using this order:

Convert file ID tokens to relative URLs
Convert stream wrapper URLs to relative URLs
Video Filter
Insert view filter
Convert URLs into links

I have checked both of these
Convert file ID tokens to relative URLs
and
Convert stream wrapper URLs to relative URLs

I have uninstalled and installed again the module, using drush. I didn't touch any node, but the logs show this:

php	24.01.2013 - 22:24	Notice: Undefined index: in _portable_path_field...	Anonymous (not verified)	
php	24.01.2013 - 22:24	Notice: Undefined index: in _portable_path_field...	Anonymous (not verified)	
php	24.01.2013 - 22:24	Notice: Undefined index: in _portable_path_field...	Anonymous (not verified)	
php	24.01.2013 - 22:24	Notice: Undefined index: in _portable_path_field...	Anonymous (not verified)	
php	24.01.2013 - 22:24	Notice: Undefined index: in _portable_path_field...	Anonymous (not verified)	
php	24.01.2013 - 22:24	Notice: Undefined index: in _portable_path_field...	Anonymous (not verified)	
system	24.01.2013 - 22:23	portable_path module enabled.	Anonymous (not verified)	
system	24.01.2013 - 22:23	portable_path module installed.	Anonymous (not verified)
system	24.01.2013 - 22:22	portable_path module uninstalled.	Anonymous (not verified)	
system	24.01.2013 - 22:21	portable_path module disabled.	Anonymous (not verified)	
solotandem’s picture

Regarding filter order, I put the portable path filters at the top (as you have them) as they need to convert the text to URLs that other filters might act upon.

Regarding the undefined index error, could you dump the values of $entity->$field_name and possibly $entity in _portable_path_field_attach_load() just before line 52? Please scrub any sensitive information before posting. It would seem that a language code is not being found. Do you have any translation modules enabled?

claudiuv’s picture

Should I go for var_dump to give you the data required ? Or should I use a better tool?

Yes, I have the translation enabled for Romanian.

Cheers,

solotandem’s picture

Either var_dump or print_r is fine. Thanks.

claudiuv’s picture

Sorry for being lame, where should I get the output ? in the node edit view ?

solotandem’s picture

See #2. Put echo print_r($entity->$field_name, TRUE); in _portable_path_field_attach_load() before line 52.

claudiuv’s picture

well I did that

    foreach ($instances as $instance) {
      if (in_array($instance['field_name'], $settings['field_names'])) {
        $field_name = $instance['field_name'];
        // Load the field to read its columns and use first column for value.
        $field = field_info_field($instance['field_name']);
        $column = array_shift(array_keys($field['columns']));
        // Get the language key from the field array.
        $language = array_shift(array_keys($entity->$field_name));
echo print_r($entity->$field_name, TRUE);
echo print_r($entity, TRUE);
        $format = $entity->{$field_name}[$language][0]['format'];
        $filters = filter_list_format($format);
        // Which of our filters is active in the format?
        $our_filters2 = array_intersect_key($our_filters, $filters);

Flushed caches. And no additional debug dumps to be seen on any node.

solotandem’s picture

That code is invoked when you try to save a node. Sorry.

claudiuv’s picture

I saved a few times the node, but I cant see the dump. I even searched page source for "entity".
Could you give me more directions, please?

claudiuv’s picture

I have modified the edit.inc file like this

<?php
/**
 * @file
 * Provides filtering of encoded URLs in fields being edited based on settings.
 *
 * @author Jim Berry ("solotandem", http://drupal.org/user/240748)
 */

/**
 * Implements hook_field_attach_load().
 *
 * @todo
 * This hook is called on entity view and edit. In both cases, each filter
 * process callback has already been invoked. Because the filtered text is in
 * the safe_value key which is rendered on entity view, we do not need to do
 * anything further on the view case.
 *
 * On entity edit, the unfiltered text (from the value key) is displayed in the
 * textarea field. In order for someone to edit this text or for an image to
 * display in a WYSIWYG editor, the portable path filters need to be processed
 * on the raw text value.
 *
 * How can we determine if this hook is being invoked as part of an edit?
 *
 * On an user entity, the safe_value omits the style attribute on image tags?
 */
function _portable_path_field_attach_load($entity_type, $queried_entities, $age, $options) {
  // Get information.
  $info = entity_get_info($entity_type);
  $formats = filter_formats();
  $settings = portable_path_config();
  $our_filters = portable_path_filter_info();

  // An entity may not have a bundle key, e.g., user.
  $bundle_key = $info['entity keys']['bundle'];
  foreach ($queried_entities as &$entity) {
$o1 = print_r($entity->$field_name, TRUE);
$o2 = print_r($entity, TRUE);
file_put_contents( '/tmp/234235729.txt', $o1 . $o2, FILE_APPEND );
    $bundle_name = isset($entity->$bundle_key) ? $entity->$bundle_key : NULL;
    $instances = field_info_instances($entity_type, $bundle_name);
    if (isset($instances[$entity_type])) {
      // Array structure is one level deeper on user than node.
      // User has $instances['user']['field_description'].
      $instances = $instances[$entity_type];
    }
    foreach ($instances as $instance) {
      if (in_array($instance['field_name'], $settings['field_names'])) {
        $field_name = $instance['field_name'];
        // Load the field to read its columns and use first column for value.
        $field = field_info_field($instance['field_name']);
        $column = array_shift(array_keys($field['columns']));
        // Get the language key from the field array.
        $language = array_shift(array_keys($entity->$field_name));
        $format = $entity->{$field_name}[$language][0]['format'];
        $filters = filter_list_format($format);
        // Which of our filters is active in the format?
        $our_filters2 = array_intersect_key($our_filters, $filters);

        if (empty($our_filters2)) {
          continue;
        }

        if (!empty($entity->$field_name) && !empty($entity->{$field_name}[$language][0][$column])) {
          foreach ($our_filters2 as $key => $filter) {
            $function = $filter['process callback'];
            if (function_exists($function)) {
              $entity->{$field_name}[$language][0][$column] = $function($entity->{$field_name}[$language][0][$column], $filter, $formats[$format]);
            }
          }
        }
      }
    }
  }
}

The txt file is not created.
find / -name 234235729.txt

However, the errors reported are still at line 52, which is a bit strange, it should be line 55 now.

I am waiting for your feedback.

Thanks,

claudiuv’s picture

At last! This is your entity, dumped

later edit: entity dump removed for privacy reasons

When trying to dump $entity->$field_name , php gives this error

PHP Fatal error: Cannot access empty property in /var/www/blabla/sites/all/modules/portable_path/includes/edit.inc on line 37

solotandem’s picture

Assigned: Unassigned » solotandem
Status: Active » Fixed

Fixed in this commit.

Status: Fixed » Closed (fixed)

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