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 empty() bug on DBPrefix #2205

Merged
merged 2 commits into from
Sep 17, 2019
Merged

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented Sep 9, 2019

Description
When Forge runs dropTable() it will check for and strip the DBPrefix from a table name if found. It does this check via (! empty($this->db->DBPrefix) ... but since DBPrefix is acquired through BaseConnection's magic __get without a corresponding __isset() empty() returns false even when it isn't empty. Because of the magic getter and the initial property we can be sure DBPrefix will always be there so it is fine to test ($this->db->DBPrefix directly. Might consider adding __isset() to BaseConnection at some point.

Checklist:

  • Securely signed commits
  • Component(s) with PHPdocs
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@MGatner
Copy link
Member Author

MGatner commented Sep 9, 2019

Since
#2206 was partly caused by this Forge issue I'm adding the fix here as well:

  • Moved migration rollback before the drop-table loop

@MGatner
Copy link
Member Author

MGatner commented Sep 14, 2019

@lonnieezell I think this one is a straight bug fix, unless you would like __isset() added to BaseConnection.

@lonnieezell
Copy link
Member

It was brought up in another issue, but adding _isset() is probably a good idea.

@MGatner MGatner merged commit 1e8e5c9 into codeigniter4:develop Sep 17, 2019
@MGatner MGatner deleted the forge-prefix-trim branch September 17, 2019 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants