Call to duplicate_files failing

I'm running into an issue that has me stumped and am looking for any insight. We have a process that takes Attachments from Emails and allows users to copy selected Attachments to Documents that are then related to the parent of the email (Cases or Opportunities). This makes finding the files a bit easier.
The process works just fine in two sandbox environments (QA & UAT). However, once the code was deployed to a Dev sandbox, we started seeing errors.
The code is successfully creating the Document with Revision, all good. But once the call goes out to duplicate the file, it fails, and I cannot see why. This is the documentation followed for duplicating a file:
Some Notes:
  • File size is small: 562K, and Maximum upload size is set to 30MB.
  • We have plenty of free disk space according to SugarCloud Insights.
  • User permissions appear to be the same as other environments.
  • Not seeing any error entries in the logs from upload_file.php.
Interestingly, while we are calling duplicate_file from upload_file.php, I am seeing a warnings in the PHP logs from download_file.php.
PHP Warning:  Trying to access array offset on false in /25.2.0/ent/include/download_file.php on line 50
Our Dev sandbox was recently created from a Production backup, so my fear is that this process will also not work in Production.
If anyone has suggestions for where to look next it would be greatly appreciated.
Thank you,
Steve.
  • Hello  , 

    If the code is working in your QA and UAT environments, I would focus on identifying what might be different in DEV. A few things that might be worth checking:

    1. Uploads folder – If the DEV instance was created as a clone of Production, did the process include the uploads/ folder? By default, Support clones do not include this folder, so it’s possible the file you are trying to copy is not present in that environment.

    2. Schedulers / Cron – If any step of the process relies on schedulers, make sure the cron job is running correctly on the DEV instance.

    3. Permissions – File or folder permissions might also be a factor. You could ask Support to run a Repair Permissions on the DEV instance to rule that out.

    4. Version / code differences – Double-check that the instances are running the same Sugar version and that all the files involved in the process are exactly the same across environments.

    If the issue still persists after these checks, in my view the next step would be to add some logging to the process so you can identify exactly where it is failing.

    Hope this helps.

    Cheers,

    André



  • Andre,

    Thank you for the reply, it was much appreciated and sent me down the correct path.

    After checking with Sugar Support I now understand that when restoring a backup to a clone/sandbox, the upload files are not restored. The upload folder did exist, but no files. This makes complete sense when I think about it. So, while the emails appeared to have attachments, the files did not exist.

    I'll be adding code to properly handle this scenario.

    Thanks again,

    Steve.