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

API - Add upgrade-safe checks to ensure table exists before reading #18135

Merged
merged 7 commits into from
Aug 14, 2020

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Aug 12, 2020

Overview

This adds efficient checks into the api (v3 and v4) to ensure a DAO table exists before trying to read from it.
This prevents hard-crashes in the UI when there are pending updates (or during the upgrade process itself)

Before

Checks on fields but not the entire table.

After

Efficiently check if a table exists (without requiring an extra query) before trying to read from it.

Technical Details

Adds information to each DAO file about what extension it belongs to (const EXT is either 'civicrm' or the name of the extension). Avoids doing version checks on non-core tables as extension checks would have to be implemented differently (a good idea but not part of this PR).

Comments

TODO: Add these checks for extensions' tables if there are pending extension upgrades.
Another TODO would be to also perform this check before attempting a join. Currently this check is limited to the primary table.

@civibot civibot bot added the master label Aug 12, 2020
@civibot
Copy link

civibot bot commented Aug 12, 2020

(Standard links)

@seamuslee001
Copy link
Contributor

Test fails look related @colemanw and also needs a rebase

@colemanw
Copy link
Member Author

@seamuslee001 I rebased & fixed the test issue

@seamuslee001
Copy link
Contributor

This looks good to me merging

@seamuslee001 seamuslee001 merged commit e1c19ea into civicrm:master Aug 14, 2020
@seamuslee001 seamuslee001 deleted the daoVersions branch August 14, 2020 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants