patrickbrouwers
Repos
36
Followers
233
Following
1

🚀 Supercharged Excel exports and imports in Laravel

11066
1683

🚀 Supercharged Excel exports for Laravel Nova Resources

336
55

Events

[BUG] MemoryCache class methods incompatible with Psr\SimpleCache\CacheInterface

Prerequisites

  • [X] Able to reproduce the behaviour outside of your code, the problem is isolated to Laravel Excel.
  • [X] Checked that your issue isn't already filed.
  • [X] Checked if no PR was submitted that fixes this problem.

Versions

  • PHP version: 8.1.4
  • Laravel version: 9.33.0
  • Nova version: 4.15.2
  • Package version: 1.3.2

Description

When attempting to install Laravel Nova Excel via Composer, I am getting the following error message:

Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed

  at vendor/maatwebsite/excel/src/Cache/MemoryCache.php:62
     58▕ 
     59▕     /**
     60▕      * {@inheritdoc}
     61▕      */
  ➜  62▕     public function get($key, $default = null)
     63▕     {
     64▕         if ($this->has($key)) {
     65▕             return $this->cache[$key];
     66▕         }

Steps to Reproduce

Attempt to install the package on the specified version of PHP

Expected behavior:

The package installs normally

Actual behavior:

The package doesnt install, instead throwing the error message shared above

Additional Information

If I manually edit the file in question (Maatwebsite\Excel\Cache\MemoryCache.php) and update the method signatures for almost all of the methods, to be compatible with the Psr\SimpleCache\CacheInterface , for example:

 public function setMultiple($values, $ttl = null)

Becomes:

 public function setMultiple($values, $ttl = null):bool

Then everything works fine and the generation of autoload files goes smoothly

Created at 5 hours ago
[BUG] MemoryCache class methods incompatible with Psr\SimpleCache\CacheInterface

Indeed has to be installed like that, the docs of the main package already reflected this, the Excel Nova docs too now.

Created at 5 hours ago

Update installation.md

Created at 5 hours ago
pull request closed
fix return types for Laravel 9 compatibility

Please take note of our contributing guidelines: https://docs.laravel-excel.com/3.1/getting-started/contributing.html Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.

1️⃣ Why should it be added? What are the benefits of this change?

2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.

3️⃣ Does it include tests, if possible?

4️⃣ Any drawbacks? Possible breaking changes?

5️⃣ Mark the following tasks as done:

  • [x] Checked the codebase to ensure that your feature doesn't already exist.
  • [ ] Take note of the contributing guidelines.
  • [ ] Checked the pull requests to ensure that another person hasn't already submitted a fix.
  • [ ] Added tests to ensure against regression.
  • [ ] Updated the changelog

6️⃣ Thanks for contributing! 🙌

Created at 5 hours ago
issue comment
fix return types for Laravel 9 compatibility

Duplicate of a few other PR's, please see my comment here: https://github.com/SpartnerNL/Laravel-Excel/pull/3737#issuecomment-1259321455

Created at 5 hours ago
issue comment
[Bug]: Wrong validation rule format returned by the RowValidator when there are other rules with extra commas

Can you try as a workaround:

'mobile_no' => [
    'required_with:country_calling_code',
    'unique:users,user_mobile_no',
]

I welcome a PR that improves this, currently no time (holidays) to look into this myself

Created at 5 hours ago
patrickbrouwers create tag 3.1.43
Created at 1 day ago

Apply fixes from StyleCI

[ci skip] [skip ci]

Created at 1 day ago

check that the $import variable is not empty (#3745)

  • check that the $import variable is not empty

  • Update ExcelTest.php

Co-authored-by: Patrick Brouwers patrickbrouwersfilm@gmail.com

Created at 1 day ago
pull request closed
check that the $import variable is not empty

check that the $import variable is not empty, avoid problems with method_exists(): Argument

TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given

Created at 1 day ago
issue comment
check that the $import variable is not empty

I've added a test for it

Created at 1 day ago

Update ExcelTest.php

Created at 1 day ago
issue comment
check that the $import variable is not empty

But that test doesn't currently fail. Can you please add a test case to that test class for this

Created at 2 days ago
issue comment
check that the $import variable is not empty

It's not really intended to be used in that way. I don't mind the fix, but I'd like to have a unit test in place for this change.

Created at 3 days ago
issue comment
check that the $import variable is not empty

When does this occur? Can you add a regression test for this?

Created at 3 days ago
[Bug]: Declaration of Maatwebsite\Excel\Cache\MemoryCache::delete($key) must be compatible with Psr\SimpleCache\CacheInterface::delete(string $key): bool

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

  • [X] Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.40

What version of Laravel are you using?

9.33.0

What version of PHP are you using?

8.1.x

Describe your issue

After performing composer update, during package autodiscovery an error is raised:

   Symfony\Component\ErrorHandler\Error\FatalError 

  Declaration of Maatwebsite\Excel\Cache\MemoryCache::delete($key) must be compatible with Psr\SimpleCache\CacheInterface::delete(string $key): bool

  at vendor/maatwebsite/excel/src/Cache/MemoryCache.php:40
     36▕ 
     37▕     /**
     38▕      * {@inheritdoc}
     39▕      */
  ➜  40▕     public function delete($key)
     41▕     {
     42▕         unset($this->cache[$key]);
     43▕ 
     44▕         return true;

It seems Maatwebsite\Excel\Cache\MemoryCache is no longer compatitble with Psr\SimpleCache\CacheInterface.

Maybe relevant. maatwebsite/excel is only installed as a consequence of installing maatwebsite/laravel-nova-excel.

How can the issue be reproduced?

Update to latest laravel with laravel-excel and perform a package autodiscovery.

What should be the expected behaviour?

No raise.

Created at 4 days ago
issue comment
[Bug]: Declaration of Maatwebsite\Excel\Cache\MemoryCache::delete($key) must be compatible with Psr\SimpleCache\CacheInterface::delete(string $key): bool

Indeed, make sure to follow the official installation instructions from our documentation

Created at 4 days ago
patrickbrouwers create tag 3.1.42
Created at 6 days ago

Revert validation to array introduced in 3.1.41 (#3742)

  • Revert "Simplify validations by using only one concern (#3642)"

This reverts commit d4fb556ebcc7edafa870d4ae2e98436c04ea2689.

Conflicts:

CHANGELOG.md

  • Revert "Allow validations with toArray (#3641)"

This reverts commit 37b4143c5f377a15438b71761572cbf281abd7d1.

Conflicts:

CHANGELOG.md

Co-authored-by: Michael van der Griendt griendt@kyos.com

Created at 6 days ago
[Bug]: Validation problem introduced in 3.1.41

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

  • [X] Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.41

What version of Laravel are you using?

9.32

What version of PHP are you using?

8.1.7

Describe your issue

In the last release a change was included to allow validation with ToArray. I believe this change is flawed. Specifically this relates to PRs #3641, #3642.

This code was introduced in Sheet.php:

        $rows = [];
        foreach ($this->worksheet->getRowIterator($startRow, $endRow) as $index => $row) {
            $row = new Row($row, $headingRow, $headerIsGrouped);
...
            if ($import instanceof WithValidation) {
                if (method_exists($import, 'prepareForValidation')) {
                    $row = $import->prepareForValidation($row, $index);
                }

                $rows = $this->validated($import, $startRow, $rows);
            }

            $rows[] = $row;
        }
    ...
    return $rows;
}

This code makes changes to $rows from inside the loop, which otherwise operates only adds to $rows by $rows[] = $row. That is already strange and will cause all rows to be validated each time the loop is run.

Furthermore, if any ValidationError is thrown from this validation call, it will not be caught the same way it is when being run from inside the regular validation process; this means that only 1 error can ever be reported.

This affects not only calls to imports implementing ToArray but also ToCollection, because internally Sheet->toCollection uses Sheet->toArray().

How can the issue be reproduced?

An Import expecting to validate multiple lines and receive errors about multiple lines will not receive them, but just a single error. Also, likely the $rows returned from the import will be incorrect.

What should be the expected behaviour?

Import validation error handling should behave like they did prior to 3.1.41 release.

Created at 6 days ago
pull request closed
Revert validation to array introduced in 3.1.41

This PR reverts changes made to validation handling, which broke the existing import workflow in certain (important) cases. See #3740.

1️⃣ Why should it be added? What are the benefits of this change? Fixes #3740

2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out. It reverts only the changes from #3641, #3642

3️⃣ Does it include tests, if possible? Not applicable.

4️⃣ Any drawbacks? Possible breaking changes? Removes the functionality to run validation directly while calling 'toArray' or 'toCollection', which was flawed.

5️⃣ Mark the following tasks as done:

  • [x] Checked the codebase to ensure that your feature doesn't already exist.
  • [x] Take note of the contributing guidelines.
  • [x] Checked the pull requests to ensure that another person hasn't already submitted a fix.
  • [ ] Added tests to ensure against regression.
  • [x] Updated the changelog

6️⃣ Thanks for contributing! 🙌

Created at 6 days ago
issue comment
[Bug]: composer update error. Caused by using php-fig/simple-cache >= v2.0

Please follow the official installation instructions

composer require psr/simple-cache:^2.0 maatwebsite/excel

https://docs.laravel-excel.com/3.1/getting-started/installation.html

Created at 1 week ago
[Bug]: composer update error. Caused by using php-fig/simple-cache >= v2.0

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

  • [X] Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.40

What version of Laravel are you using?

9.31.0

What version of PHP are you using?

8.1.10

Describe your issue

When execute 'composer update', it returned the error message belows.

PHP Fatal error: Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed in /usr/share/nginx/html/SES-PROJECT/releases/1/backend/vendor/maatwebsite/excel/src/Cache/MemoryCache.php on line 62

How can the issue be reproduced?

Run this command.

composer require maatwebsite/excel

or

composer update

What should be the expected behaviour?

Run command finish and success.

Created at 1 week ago
pull request closed
Make Maatwebsite\Excel\Cache\MemoryCache fully compatiple with Psr\SimpleCache\CacheInterface

Please take note of our contributing guidelines: https://docs.laravel-excel.com/3.1/getting-started/contributing.html Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.

1️⃣ In Larave 9 and php 8.1 implemented interfaces are required to be compatiple with each other, the package fails to meet this rrequirement causing Laravel to throw an Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed error during installation and also producing causing IDE redlines, this pull requires at it's best attempts to fullfill this requirement.

2️⃣ It does not.

3️⃣ No tests are included

4️⃣ No drawbacks and no known possible breaking changes.

5️⃣ Mark the following tasks as done:

  • [x] Checked the codebase to ensure that your feature doesn't already exist.
  • [x] Take note of the contributing guidelines.
  • [x] Checked the pull requests to ensure that another person hasn't already submitted a fix.
  • [ ] Added tests to ensure against regression.
  • [x] Updated the changelog

6️⃣ Thanks for contributing! 🙌

Created at 1 week ago
issue comment
Make Maatwebsite\Excel\Cache\MemoryCache fully compatiple with Psr\SimpleCache\CacheInterface

Hey thanks for your PR. Just as with the other PR's around this subject I have to close it as it's not compatible with the backwards compatibly (PHP versions) this current release is currently on. A fix was already released to make sure it won't install a newer version of the cache interface.

Created at 1 week ago
issue comment
Prevent install of psr/simplecache 3.0

I don't see an immediate benefit of adding return types to the MemoryCache, it shouldn't impact anybody as it is an internal class. Will be added when we do the a 4.x version of this package.

Created at 1 week ago
issue comment
Fixed MemoryCache functions Declaration to compatible with Psr\SimpleCache\CacheInterface

A fix was already released without a breaking change. Using this PR would cause a lot of applications on older versions to not be able to use this package anymore, that's not something we have planned for now.

Created at 1 week ago
[Bug]:

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

  • [X] Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.40

What version of Laravel are you using?

9.26.1

What version of PHP are you using?

8.1.8

Describe your issue

For some imports, we just get a black screen, see screenshot bellow. Imports are not done and we have no more info. It is not a size problem as we have 3000 lines to import that bug and previously we imported without any problem 5000 lines.

image

How can the issue be reproduced?

We can send you privately a file with the bug.

What should be the expected behaviour?

Import should be done with no problem

Created at 1 week ago