SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.22k stars 1.91k forks source link

[Bug]: Row headings missing after update to Laravel 11 #4182

Open aceraven777 opened 1 month ago

aceraven777 commented 1 month ago

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

What version of Laravel Excel are you using?

3.1.55

What version of Laravel are you using?

11.20.0

What version of PHP are you using?

8.3.9

Describe your issue

I'm exporting a CSV file on queue. And after updating to Laravel 11 the export seems to break the exporting of headings. The headings are missing.

The weird thing is this is working on my local environment, in my local environment I'm using Laravel sail (I'm using minio):

QUEUE_CONNECTION=redis

My live environment is in Vapor (i'm using AWS S3):

QUEUE_CONNECTION=sqs

How can the issue be reproduced?

Download fresh install of Laravel 11, and use queue export and there's no headings

What should be the expected behaviour?

There should be headings on the csv file

aceraven777 commented 3 weeks ago

@bpudenz commented related on this issue.

Comment on issue #1921

bpudenz commented 3 weeks ago

I tried to dig in this afternoon and manually tweak it similar to the previous patch in the Sheet::open method with no luck.

Locally it works fine. Whats odd is my QA has exports that worked 10 days ago. I squashed a couple commits, so I'm not certain if a version changed in there, or if its a config value causing it or what. Not sure its helpful, but these are the only non-default config changes for working in a multi-server/queue environment:

'local_path' => sys_get_temp_dir(),
'local_permissions' => [
    'dir' => 0755,
    'file' => 0644,
],
'remote_disk' => 's3',
'remote_prefix' => null,
'force_resync_remote' => true,

class ClassName extends ExcelExport
    public function setUp()
    {
        $this->fromTable();
        $this->queue();
        $this->withWriterType(Excel::CSV);
        $this->withChunkSize(500);
    }
aceraven777 commented 3 weeks ago

I think the problem is somewhere here: https://github.com/SpartnerNL/Laravel-Excel/compare/3.1.50...3.1.51

When I use 3.1.50 its working, but on 3.1.51 its not working.

patrickbrouwers commented 3 weeks ago

I never use the multiserver setup, so I can't help here. If anyone figures out how perhaps https://github.com/SpartnerNL/Laravel-Excel/pull/4034 causes this, feel free to PR a fix.

aceraven777 commented 3 weeks ago

I think I manage to pinpont where the problem is. The problem is in the file src/Writer.php, around line 169,

if ($temporaryFile instanceof RemoteTemporaryFile && !$temporaryFile->existsLocally()) {
    $temporaryFile = resolve(TemporaryFileFactory::class)
        ->makeLocal(Arr::last(explode('/', $temporaryFile->getLocalPath())));
}

If I commented that code it works on our vapor setup.

FelipeSobral commented 1 week ago

I'm having the same issue but I'm using Laravel 10 running on Bref

patrickbrouwers commented 1 week ago

Can you please test https://github.com/SpartnerNL/Laravel-Excel/pull/4198 If anything else to detect serverless is needed for Bref, please leave a comment on the PR

aceraven777 commented 6 days ago

I've tested it on Vapor, it seems this fixes our issue.