APY / APYDataGridBundle

Symfony Datagrid Bundle
MIT License
492 stars 344 forks source link

Bugfix: Trying to access array offset on value of type null (strict types) #1061

Closed ksaveras closed 2 years ago

ksaveras commented 3 years ago

When the application calls $column->getData(), PHP outputs warning message: Trying to access array offset on value of type null

env: PHP 7.4

Trying to access array offset on value of type null

ksaveras commented 3 years ago

Hey, is there anyone alive? Anyone who cares about improving this package?

DonCallisto commented 3 years ago

Hi. Actually this bundle is quite abandoned. We changed several times the maintainers but everytime the pace is not good as it should be. I would suggest to drop the dependency (as we did) and go for other solutions.

fkrauthan commented 2 years ago

@DonCallisto sorry for the late replay but with what bundle did you replace this one? So far I couldn't find any bundle that makes data column work as easy as this one (without dictating a fixed UI).

DonCallisto commented 2 years ago

We developed a custom in-house solution based on our needs but we can't open source it as has some specific logic of our software. Maybe in the future we'll be able to decouple a little bit and release it for everyone but for the moment I cannot suggest an alternative.

natewiebe13 commented 2 years ago

@fkrauthan in case you're looking for a drop-in replacement, we ended up forking it: https://github.com/northernco/NorthernDatagridBundle, I don't believe there should be much at all regarding breaking changes, assuming you're using more modern versions of php and libs.

Regarding longevity, we're still deciding if we want to make the bundle compatible with Symfony 6 or go a totally different route. If we do decide to move forward with this bundle, then we're likely going to be doing a massive overhaul. But at the very least, this should allow you to update some things in the meantime.

Mopster commented 2 years ago

I updated my fork with the 7.4 updates, but there seems to be a bug in the update in blocks.html.twig. The filtered value isn't showing in the filter input field after submitting. The grid filters, but the filter value isn't showing. And the current filter value will be lost when adding another filter.

It concerns following piece of code on line 331 in blocks.html.twig in block grid_column_filter_type_input and line 354 in block grid_column_filter_type_select.

{% if column %}
    {% set op = column.defaultOperator %}
    {% set from = null %}
    {% set to = null %}
{% else %}
    {% set op = column.data.operator is defined ? column.data.operator : column.defaultOperator %}
    {% set from = column.data.from is defined ? column.data.from : null %}
    {% set to = column.data.to is defined ? column.data.to : null %}
{% endif %}

Replacing the above by the following code seems to have fixed it.

{% if column and column.data %}
    {% set op = column.data.operator is defined ? column.data.operator : column.defaultOperator %}
    {% set from = column.data.from is defined ? column.data.from : null %}
    {% set to = column.data.to is defined ? column.data.to : null %}
{% else %}
    {% set op = column.defaultOperator %}
    {% set from = null %}
    {% set to = null %}
{% endif %}

There could be a better way of handling this though.

deguif commented 2 years ago

@Mopster should be fixed by #1069 but no answer from maintainers of this project

npotier commented 2 years ago

Hello, thank you for reporting this issue, and for the PR. it is now merged, I'm closing this issue ✌️