Forum

Thread tagged as: Question, Add-on-development, Runway

PerchCollectionImporter in Scheduled Task

Hi All,

I had what i thought was a working scheduled task, but in testing i failed to notice that it was running because i was pretty much always logged into the admin, so when the cron job is setup it keeps failing, with the following error:

Notice: Undefined index: userID in C:\source\***\perch\core\lib\PerchBase.class.php on line 125

Fatal error: Call to a member function itemID() on null in C:\source\***\perch\core\runway\lib\PerchCollectionImporter.class.php on line 76

i know the problem is about being logged in, becuase when i log in, run the scheduled task it works, so i am not sure if there is some extra context/information i need to pass to the collection importer to get this to work? can i just add the userID manually to the add_item call?

Thanks,

Rob

Roberto Modica

Roberto Modica 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It certainly looks that way. It's not something you're doing - I think it's a bug.

Hi Drew,

if i have to refactor to not use the collection importer (i will cry a little) i will, is there any other "safe-ish" way to do it opposed to just using the data access classes?

Thanks,

Rob

I have found the place where the "issue" is and i will patch it for now. I understand this will be overwritten with updates and not recommended (hopefully one patch will get rid of the need), but it is a small change to not effect what is there and get the collection importer to work and leave the rest as is:

There is a call $CurrentUser->id(); in the create method of the PerchContent_CollectionItems class which what is obviously not working as i am not logged in (when i hardcoded a value it worked, the scheduled task runs)

        $Users          = new PerchUsers;
        $CurrentUser    = $Users->get_current_user();

        $data['itemUpdatedBy'] = $CurrentUser->id();

Thanks,

Rob

Drew McLellan

Drew McLellan 2638 points
Perch Support

This should be fixed in 3.0.11