Bug? in scheduling jobs, no authorID?

Permalink 1 user found helpful
Hello all,

I have a cronjob which curl's the url that runs all of the jobs.

Works fine, but has 1 minor problem, which kills the job with a mysql error.

In my job i download images and put them as a new file or a new fileversion (if it's an update) in the library. All using c5 functions, works great!

Running the job manually i use the admin account and i have no errors.

But when i run the job through the cronjob, the fileversions that are being saved in mysql, have no authorid, resulting in a mysql error, which kills the process.

mysql error: [1048: Column 'fvAuthorUID' cannot be null] in EXECUTE("insert into FileVersions (fID,fvID,fvFilename,fvPrefix,fvGenericType,fvSize,fvTitle,fvDescription,fvTags,fvIsApproved,fvDateAdded,fvApproverUID,fvAuthorUID,fvActivateDatetime,fvHasThumbn...


Is this a bug in the job run tool, or in the fileversion function, or is something else wrong?

Hope to get some help! Anyone? Thanks!!

NUL76
 
NUL76 replied on at Permalink Best Answer Reply
NUL76
I figured it out.

Strangly, if you run the jobs, through a cronjob which uses curl for the jobs automated url, adding new files or updating a file with a new version, you get an error since he misses a user account.

Fix: log in as a user with sufficient rights, say admin which has fID 1.

User::loginByUserID(1);


Done!
arrestingdevelopment replied on at Permalink Reply
arrestingdevelopment
I'm having the same problem with insufficient rights using CURL in a PHP file I've got scheduled to run daily.

I setup the PHP file to curl the "Automated Jobs" URL, but get an "Access Denied" error reported each time it runs.

Here's what I used in the PHP file being called by cron on the server:
<?php
$ch = curl_init("path-to-automated-jobs-URL");
$fp = fopen("scheduled_task_log.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>


Can this be modified so that it has the right privileges to run the task?

Thanks!

- John