Laravel-excel: [Bug] ~2.1.0 Ignored referenced variables in closure

Created on 29 Mar 2016  路  2Comments  路  Source: Maatwebsite/Laravel-Excel

"maatwebsite/excel": "~2.1.0", "laravel/framework": "5.1.*"

->chunk(10, function($student_spreadsheet) use (&$current_row, &$errors, &$successful_rows, &$remove)

use() variables are completely ignored

I was using 2.0.9, as soon as I updated to ~2.1.0 all of the referenced variables in the closure are getting ignored, as in they stay at the initial value. I don't quite get why..

This is the full code:

Excel::filter('chunk')->selectSheetsByIndex(0)->load('storage/app/processed_files/'.$target_filename, 'UTF-8', true)->noHeading()->formatDates(FALSE)
                ->chunk(10, function($student_spreadsheet) use (&$current_row, &$errors, &$successful_rows, &$remove)

Most helpful comment

When using chunk, you are executing every chunk sandboxed, because the chunk is put on the queue (when no queue driver used, it uses the laravel sync driver). This means it's not possible to pass variables by reference.

This feature was added to 2.1.0 to tackle performance issues. The 3rd parameter of chunk() accepts a boolean to enable/disable this functionality.

All 2 comments

When using chunk, you are executing every chunk sandboxed, because the chunk is put on the queue (when no queue driver used, it uses the laravel sync driver). This means it's not possible to pass variables by reference.

This feature was added to 2.1.0 to tackle performance issues. The 3rd parameter of chunk() accepts a boolean to enable/disable this functionality.

hi i am larage values store in one array how to down csv down load chunk by chunk
please any one help with. need to google api big data

Was this page helpful?
0 / 5 - 0 ratings