After a big import a bunch of notices were thrown:

Notice: Indirect modification of overloaded property FeedsSource::$state has no effect in FeedsSource->import() (line 343
Notice: Indirect modification of overloaded property FeedsSource::$state has no effect in FeedsSource->import() (line 350
Notice: Undefined index: time_field in FeedsSource->import() (line 369
Notice: Indirect modification of overloaded property FeedsSource::$state has no effect in FeedsSource->import() (line 343
Notice: Indirect modification of overloaded property FeedsSource::$state has no effect in FeedsSource->import() (line 350

from a first glace it seams that import has happened successfully yet I am not entirely sure if there is nothing to concern with because I don't' quit get what those error mean.
I would fix whatever is wrong if I could understand what exactly is happening. Indirect modification of overloaded property FeedsSource::$state has no effect pretty cryptic...

Comments

agoradesign’s picture

Hi,
how did you solve this problem? I'm getting exactly the same error. I've written a custom function, which iterates through serveral Feeds importers, running them one after another. One of them is called twice, but with different source files. When this importer is running the second time, I'm getting the errors.

Here's the part of my code, which runs a single importer:

<?php
 
protected function _runSingleImport($import_definition) {
   
$source = feeds_source($import_definition['name']);
   
$config = $source->existing()->getConfig();
   
$config['FeedsFileFetcher']['source'] = $import_definition['source'];
   
$source->setConfig($config);
   
   
$status = FEEDS_BATCH_ACTIVE;
    while (
FEEDS_BATCH_COMPLETE != $status) {
     
$source->existing()->setConfig($config);
      try {
       
$status = $source->existing()->import();
      }
      catch (
FeedsNotExistingException $e) {
       
// Do nothing.
     
}
      catch (
Exception $e) {
       
$source->log('import', $e->getMessage(), array(), WATCHDOG_ERROR);
       
// TODO additional/other error handling (email, abort, ....)??????
       
$status = FEEDS_BATCH_COMPLETE;
      }
    }
  }
?>
giffenk’s picture

I was getting a similar error when attempting to perform multiple runs of the same feed via code. Tracked the issue to the FeedsSource object not having the same structure after the end of the first import. The "state" variables where different.

The following snippet got rid of the error:

  for($i = 1; $i < $multi_count; $i++) {
    $source = feeds_source( $importer_id );
    // the feeds source does not get cleaned up properly, so ask it for its states so they are all present.
    $source->state( FEEDS_FETCH );
    $source->state( FEEDS_PROCESS );
    $source->state( FEEDS_PROCESS_CLEAR );
    ...
vibrasphere’s picture

Issue summary:View changes

Well? Anything new? I get this with just 500 imports from XML. How do I use this code above?

MegaChriz’s picture

You should use the code from #2 if you are executing Feeds importers programmatically and more than once during the same request. The code should be added to the code that is performing the import programmatically. This will be most likely in your own custom module.

I've made a function in my own module that looks similar to this:

<?php
/**
 * Imports data using a Feeds importer.
 *
 * @param string $importer_id
 *   The importer to use.
 * @param array $config
 *   Configuration for the importer.
 */
function mymodule_feeds_importer_execute($importer_id, array $config) {
 
$source = feeds_source($importer_id, 0);

 
// Get importer.
 
$importer = $source->importer();
 
// Change importer config.
  // (...)

  // Import!
 
while (FEEDS_BATCH_COMPLETE != $source->import());

 
// Clean up states.
 
$source->state(FEEDS_FETCH);
 
$source->state(FEEDS_PROCESS);
 
$source->state(FEEDS_PROCESS_CLEAR);

 
// Clear messages from Feeds.
 
drupal_get_messages('status');
}
?>

I've left out the details of changing any configuration to the importer when this function gets called.

vibrasphere’s picture

All I use is some code for a small custom module I found floating around the web, so I don't really know what the hell is going.

<?php
function mymodyle_xml_industry_people_cron() {
  $name = 'industry_people';
  $source = feeds_source($name);
  $source->import();
}

I use this because default hourly cron runs don't trigger Feeds imports. So since I have four feeds, I set up four modules with this code for each feed lol. Sorry I'm no dev, I have no idea what I'm doing, I just want my feeds autoimport work.

timdavison’s picture

Thanks giffenk and MegaChriz - I had the same notices and this worked just great.

vibrasphere - try adding the three lines of code
$source->state(FEEDS_FETCH);
$source->state(FEEDS_PROCESS);
$source->state(FEEDS_PROCESS_CLEAR);

just after your $source->import(); for each of your four modules.