Skip to content

Fix setup Red Screen Of Death with bad DB query#1160

Merged
nielsdrost7 merged 4 commits intoInvoicePlane:developmentfrom
sudwebdesign:good-setup-db-error-msg_try-again
Dec 29, 2024
Merged

Fix setup Red Screen Of Death with bad DB query#1160
nielsdrost7 merged 4 commits intoInvoicePlane:developmentfrom
sudwebdesign:good-setup-db-error-msg_try-again

Conversation

@sudwebdesign
Copy link
Copy Markdown
Collaborator

@sudwebdesign sudwebdesign commented Dec 28, 2024

Description

After tested (with real data backup of 1.5.11 version) i get an error
CI say Call to undefined method CI_DB_mysqli_driver::_error_message()

Motivation and Context

Does it solve a provlem with setup.

  • Now: All setup db query with error return a message and Try again button appear,
  • Before:
    ++ Call to undefined method CI_DB_mysqli_driver::_error_message() or
    ++ Red Screen Of Death

Screenshots (if appropriate):

To test:

  • 1 Remove in ip_version the fourth last lines
    IP-remove-DB-ip_versions-1 5 12

  • 2 Go to index.php/setup and continue to upgrade_database
    IP-upgrade_tables_errors_do_try-again

  • 3 Continue
    IP-upgrade_tables_after-try-again

  • 4 Rude Test Remove all sql versions, (Just only 1.0.0 in list of ip_version table)
    IP-upgrade_tables_errors_do_try-again-from-1 0 0
    This is just end of page, but before are numerous errors, but if click on Try-again return same as image 3 (Continue).

Pull Request Checklist

  • My code follows the code formatting guidelines.
  • I have an issue ID for this pull request.
  • I selected the corresponding branch.
  • I have rebased my changes on top of the corresponding branch.

Issue Type (Please check one or more)

  • Bugfix
  • Improvement of an existing Feature
  • New Feature

Complete InvoicePlane#1147
[Solve Red screen Of Death of bad DB query in
CI3](https://stackoverflow.com/questions/7843406/codeigniter-how-to-catch-db-errors#54519533)

Fix Call to undefined method CI_DB_mysqli_driver::_error_message()
The _error_message() function unexist in CI3.1.13:
`vendor/codeigniter/framework/system/database/DB_driver.php`

+ Indents: tab2spaces
@sudwebdesign
Copy link
Copy Markdown
Collaborator Author

#idea
A little script to go on bottom page on content loaded to be unafraid by CI errors?

window.scrollTo(0, document.body.scrollHeight);

Js from: https://stackoverflow.com/a/11715670

@nielsdrost7
Copy link
Copy Markdown
Contributor

nielsdrost7 commented Dec 29, 2024

@sudwebdesign I like the solution.
But then after Try again will the upgrade continue?

I would rather (also) to update the database properly and then continue. I think the version 1.5.12 was missing from the versions table and that causes the problem.

  • if (mysql error message 1150 or whatever)
  • add 1.5.12 as version
  • keep going and continue the rest of the tables
    (Hope it makes sense)

@nielsdrost7
Copy link
Copy Markdown
Contributor

This error only occurs when:

  • the database update for 1.5.12 has been applied (ip_login_log table)
  • but the version update has not been applied

and that's a very legitimate situation

@sudwebdesign
Copy link
Copy Markdown
Collaborator Author

sudwebdesign commented Dec 29, 2024

hi, @nielsdrost7

But then after Try again will the upgrade continue?

With this, it apply only if sql query it applicable and have no error at first time (after configure_database step), only return errors message(s) and Try again button appear (and all of 0xx.1.x.x.sql missing at added in ip_versions) after click on Try again do nothing (speedy return) All possible (missing?) update applied, Click on continue go to complete (last) step. Click on Login Button and after Logged in it work like charm.

Note: The DB no stop on error because $this->db->db_debug = false; (this is the secret)
and (maybe) the DB work this in production ENVIRONMENT?

EDIT If no update need just show Continue button ;-)

@sudwebdesign
Copy link
Copy Markdown
Collaborator Author

@nielsdrost7

This error only occurs when ...

Call to undefined method CI_DB_mysqli_driver::_error_message()

Always if no error $error['code'] === 0 (in My first test) and need sql to be upgrade app.
(or error different of 1050 or 1060)

Because The _error_message() function don't exist and make a fatal error.
And if no error (code = 0) go to inside if meaculpa

With this solution, all error are returned to the user (No DB Red Screen Of Death).
User never blocked by setup.

Click Try again -> Continue -> Login

@sudwebdesign
Copy link
Copy Markdown
Collaborator Author

@nielsdrost7
Have an idea:
At line 55

            $this->db->db_debug = false;

add IP_DEBUG like this:

            $this->db->db_debug = IP_DEBUG;

Good idea?

@nielsdrost7
Copy link
Copy Markdown
Contributor

Good idea?

Yep, go for it

@sudwebdesign
Copy link
Copy Markdown
Collaborator Author

IP_DEBUG is in place.

@nielsdrost7
Copy link
Copy Markdown
Contributor

I'll merge it and make the final 1.6.2 release.
Thank you very much @sudwebdesign !
You've saved the day!

@nielsdrost7 nielsdrost7 merged commit bb5b8d2 into InvoicePlane:development Dec 29, 2024
@sudwebdesign sudwebdesign deleted the good-setup-db-error-msg_try-again branch December 29, 2024 21:06
nielsdrost7 added a commit that referenced this pull request Dec 30, 2024
## New Contributors
Huge thanks to @sudwebdesign , @xam-ps  and @AeroBytesNL for helping. Without you guys this release wouldn't have been possible

* @sudwebdesign made their first contribution in #1149
* @VizardAlpha made their first contribution in #1129
* @pumpi made their first contribution in #1079
* @jmclaren7 made their first contribution in #1013
* @RobiNN1 made their first contribution in #1014
* @xeruf made their first contribution in #1061
* @NiklasSchmitt made their first contribution in #1073
* @redxtech made their first contribution in #1098

## What's Changed
* Add buttons on client view to delete note (Ajax) by @sudwebdesign in #1149
* Translate Client "Extra Field Title" to complete #1003 by @sudwebdesign in #1150
* [IP-1146]: after posting a Payments Form when amount > inv. total by @sudwebdesign in #1151
* [IP-1147]: Fix setup sql filenames by @sudwebdesign in #1152
* [IP-1130]: Added required input check on full page loaded to fix #1130 by @AeroBytesNL in #1155
* bug-fix-#1147-error-on-database-migration by @AeroBytesNL in #1159
* Fix setup Red Screen Of Death with bad DB query by @sudwebdesign in #1160
* **[IP-1128]**: Update QrCode.php wrong variable by @VizardAlpha in #1129
* Improve download function in #1127
* Chore: Fix upload_file function in #1141
* Show list of themes on Windows by @RobiNN1 in #1014
* [IP-1038]: Fix for issue 1038: Wrong translation string in setup by @naui95 in #1039
* [IP-1012]: Revert change to invoice_logo() by @jmclaren7 in #1013
* Slight improvements to README.md by @xeruf in #1061
* [IP-1070] by @naui95 in #1071
* [IP-1072] Fixed broken customer-link in projects-widget on dashboard. by @NiklasSchmitt in #1073
* [IP-1078]: ZUGFeRD Name should not be user name by @pumpi in #1079
* [IP-1006]: feature: payments v1.6.2 by @naui95 in #1046
* added information on theming by @naui95 in #1087
* [IP-1097]: add docker publish workflow by @redxtech in #1098
* [IP-841]: Copy Quote UI feedback by @Verony-makesIT in #932
* [IP-998]: copy all fields available in quotes by @naui95 in #1086
* [IP-1083]: Add pagination for tabs in client detail by @pumpi in #1084
* [IP-731]: Add another digit for quantity (new version) by @naui95 in #1112
* [IP-1003]: Add extra field title by nielsdrost7 in #1101
* add function to check post variables by nielsdrost7 in #1090
* [IP-1096] Payments array variable gets lost for invoices by nielsdrost7 in #1104
* Chore: add pint by nielsdrost7 in #1081
* [IP-1033] creation dates of invoices should never be changed by nielsdrost7 in #1040
* [IP-1034]: Fix error where default_language at some point switches to English by nielsdrost7 in #1035
* Make sure we don't get unintended output in our PDF files by nielsdrost7 in #1089
* [IP-1010]: Add php-dom and php-xml to the Dockerfile by nielsdrost7 in #1110
* Special project by nielsdrost7 in #1120
* [IP-1063]: Allowing for Dynamic Properties (**PHP 8.2**) by nielsdrost7 in #1117


Co-authored-by: Thomas Ingles
Co-authored-by: AutiCodes
Co-authored-by: AeroBytes
Co-authored-by: naui95
Co-authored-by: VeRony
Co-authored-by: Marc Heiduk
Co-authored-by: Róbert Kelčák
Co-authored-by: John Mclaren
Co-authored-by: Janek
Co-authored-by: Niklas
Co-authored-by: stephan4p
Co-authored-by: pumpi
Co-authored-by: der-peer
Co-authored-by: Nathan Mattes
Co-authored-by: Kevin Joudrier
Co-authored-by: Gabe Dunn
Co-authored-by: VizardAlpha
ThierryHFR pushed a commit to ThierryHFR/InvoicePlane that referenced this pull request Dec 21, 2025
Huge thanks to @sudwebdesign , @xam-ps  and @AeroBytesNL for helping. Without you guys this release wouldn't have been possible

* @sudwebdesign made their first contribution in InvoicePlane#1149
* @VizardAlpha made their first contribution in InvoicePlane#1129
* @pumpi made their first contribution in InvoicePlane#1079
* @jmclaren7 made their first contribution in InvoicePlane#1013
* @RobiNN1 made their first contribution in InvoicePlane#1014
* @xeruf made their first contribution in InvoicePlane#1061
* @NiklasSchmitt made their first contribution in InvoicePlane#1073
* @redxtech made their first contribution in InvoicePlane#1098

* Add buttons on client view to delete note (Ajax) by @sudwebdesign in InvoicePlane#1149
* Translate Client "Extra Field Title" to complete InvoicePlane#1003 by @sudwebdesign in InvoicePlane#1150
* [IP-1146]: after posting a Payments Form when amount > inv. total by @sudwebdesign in InvoicePlane#1151
* [IP-1147]: Fix setup sql filenames by @sudwebdesign in InvoicePlane#1152
* [IP-1130]: Added required input check on full page loaded to fix InvoicePlane#1130 by @AeroBytesNL in InvoicePlane#1155
* bug-fix-InvoicePlane#1147-error-on-database-migration by @AeroBytesNL in InvoicePlane#1159
* Fix setup Red Screen Of Death with bad DB query by @sudwebdesign in InvoicePlane#1160
* **[IP-1128]**: Update QrCode.php wrong variable by @VizardAlpha in InvoicePlane#1129
* Improve download function in InvoicePlane#1127
* Chore: Fix upload_file function in InvoicePlane#1141
* Show list of themes on Windows by @RobiNN1 in InvoicePlane#1014
* [IP-1038]: Fix for issue 1038: Wrong translation string in setup by @naui95 in InvoicePlane#1039
* [IP-1012]: Revert change to invoice_logo() by @jmclaren7 in InvoicePlane#1013
* Slight improvements to README.md by @xeruf in InvoicePlane#1061
* [IP-1070] by @naui95 in InvoicePlane#1071
* [IP-1072] Fixed broken customer-link in projects-widget on dashboard. by @NiklasSchmitt in InvoicePlane#1073
* [IP-1078]: ZUGFeRD Name should not be user name by @pumpi in InvoicePlane#1079
* [IP-1006]: feature: payments v1.6.2 by @naui95 in InvoicePlane#1046
* added information on theming by @naui95 in InvoicePlane#1087
* [IP-1097]: add docker publish workflow by @redxtech in InvoicePlane#1098
* [IP-841]: Copy Quote UI feedback by @Verony-makesIT in InvoicePlane#932
* [IP-998]: copy all fields available in quotes by @naui95 in InvoicePlane#1086
* [IP-1083]: Add pagination for tabs in client detail by @pumpi in InvoicePlane#1084
* [IP-731]: Add another digit for quantity (new version) by @naui95 in InvoicePlane#1112
* [IP-1003]: Add extra field title by nielsdrost7 in InvoicePlane#1101
* add function to check post variables by nielsdrost7 in InvoicePlane#1090
* [IP-1096] Payments array variable gets lost for invoices by nielsdrost7 in InvoicePlane#1104
* Chore: add pint by nielsdrost7 in InvoicePlane#1081
* [IP-1033] creation dates of invoices should never be changed by nielsdrost7 in InvoicePlane#1040
* [IP-1034]: Fix error where default_language at some point switches to English by nielsdrost7 in InvoicePlane#1035
* Make sure we don't get unintended output in our PDF files by nielsdrost7 in InvoicePlane#1089
* [IP-1010]: Add php-dom and php-xml to the Dockerfile by nielsdrost7 in InvoicePlane#1110
* Special project by nielsdrost7 in InvoicePlane#1120
* [IP-1063]: Allowing for Dynamic Properties (**PHP 8.2**) by nielsdrost7 in InvoicePlane#1117

Co-authored-by: Thomas Ingles
Co-authored-by: AutiCodes
Co-authored-by: AeroBytes
Co-authored-by: naui95
Co-authored-by: VeRony
Co-authored-by: Marc Heiduk
Co-authored-by: Róbert Kelčák
Co-authored-by: John Mclaren
Co-authored-by: Janek
Co-authored-by: Niklas
Co-authored-by: stephan4p
Co-authored-by: pumpi
Co-authored-by: der-peer
Co-authored-by: Nathan Mattes
Co-authored-by: Kevin Joudrier
Co-authored-by: Gabe Dunn
Co-authored-by: VizardAlpha
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