Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [Table] field named data will produce bugged output #8054

Merged
merged 4 commits into from
Oct 26, 2023

Conversation

ping-yee
Copy link
Contributor

@ping-yee ping-yee commented Oct 17, 2023

Description
Fixes #8051

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added bug Verified issues on the current code behavior or pull requests that will fix them tests needed Pull requests that need tests labels Oct 18, 2023
@kenjis
Copy link
Member

kenjis commented Oct 18, 2023

@ping-yee Can you add test code?

@kenjis kenjis changed the title fix: fix the field named data will produce bugged output problem. fix: [Table] field named data will produce bugged output Oct 18, 2023
@ping-yee
Copy link
Contributor Author

@kenjis Done.

@kenjis kenjis removed the tests needed Pull requests that need tests label Oct 18, 2023
@@ -265,7 +265,7 @@ protected function _prepArgs(array $args)
// If there is no $args[0], skip this and treat as an associative array
// This can happen if there is only a single key, for example this is passed to table->generate
// array(array('foo'=>'bar'))
if (isset($args[0]) && count($args) === 1 && is_array($args[0]) && ! isset($args[0]['data'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the data excluded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will cause the setHeading function to be executed incorrectly when the heading field contain named data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The && ! isset($args[0]['data']) came from this commit: bcit-ci/CodeIgniter@f0b69a85
Are you absolutely sure that just removing it does not cause another issue?
Frankly, I don't get the code yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure but the all of the test cases get passed.
And I also don't get where will use this condition and the data processing of the array field contains data so far.

Or we can add one more process to check that whether the heading array has been handled correctly when the table is being generated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the all of the test cases get passed.

Yes. But we cannot see the coverage in Coveralls.

coverage/coveralls — Target branch is ahead of PR base. Rebase the PR to fix.

Can you rebase the PR branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rebase the PR branch?

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my usage of the table class (quite extensive) I have not noticed any issues thus far with the patch applied.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you all!

@kenjis kenjis added the help wanted More help is needed for the proper resolution of an issue or pull request label Oct 19, 2023
@kenjis
Copy link
Member

kenjis commented Oct 19, 2023

If anyone has a good understanding of the Table's code, please review this PR.

@kenjis
Copy link
Member

kenjis commented Oct 26, 2023

This bug has been introduced in:
c7b02d89#diff-2ca8e500cfe5125fe8fb57a83cdf78c178594f553e4639012bef5a23634c7e97L439-R482
So CI3 is no longer a reference because the code has changed from CI3.

@kenjis
Copy link
Member

kenjis commented Oct 26, 2023

The Table class is well-tested, and I don't see the reason to exclude 'data'.
So I merge this.
Screenshot 2023-10-27 5 44 48

@kenjis kenjis merged commit 407c108 into codeigniter4:develop Oct 26, 2023
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them help wanted More help is needed for the proper resolution of an issue or pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: HTML Table Class fails with table column named 'data'.
3 participants