Project60 / Project60/org.project60.banking
Importing batch sometimes exceed reference column length limit
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 22
- Forks
- 45
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 7
Description
It is possible to create an importer with a batch reference that will cause an error because of the generated reference exceeds the column length in the database. For someone creating an importer plugin this is difficult to expect that the code doesn't check the length. This is an example of error in the log :
[debug] $backTrace = #0 /srv/www/d7-master/web/sites/all/modules/civicrm/CRM/Core/Error.php(236): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /srv/www/d7-master/web/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(922): CRM_Core_Error::handle(Object(DB_Error))
#2 /srv/www/d7-master/web/sites/all/modules/civicrm/packages/DB.php(987): PEAR_Error->__construct("DB Error: unknown error", -1, 16, (Array:2), "UPDATE civicrm_bank_tx_batch SET issue_date = 20191022115829 , reference = ...")
#3 /srv/www/d7-master/web/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(575): DB_Error->__construct(-1, 16, (Array:2), "UPDATE civicrm_bank_tx_batch SET issue_date = 20191022115829 , reference = ...")
#4 /srv/www/d7-master/web/sites/all/modules/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "UPDATE civicrm_bank_tx_batch SET issue_date = 20191022115829 , reference = ...", "DB_Error", TRUE)
#5 /srv/www/d7-master/web/sites/all/modules/civicrm/packages/DB/common.php(1920): PEAR->__call("raiseError", (Array:7))
#6 /srv/www/d7-master/web/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-1, NULL, NULL, "UPDATE civicrm_bank_tx_batch SET issue_date = 20191022115829 , reference = ...", "1406 ** Data too long for column 'reference' at row 1")
#7 /srv/www/d7-master/web/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#8 /srv/www/d7-master/web/sites/all/modules/civicrm/packages/DB/common.php(1229): DB_mysqli->simpleQuery("UPDATE civicrm_bank_tx_batch SET issue_date = 20191022115829 , reference = ...")
#9 /srv/www/d7-master/web/sites/all/modules/civicrm/packages/DB/DataObject.php(2416): DB_common->query("UPDATE civicrm_bank_tx_batch SET issue_date = 20191022115829 , reference = ...")
#10 /srv/www/d7-master/web/sites/all/modules/civicrm/packages/DB/DataObject.php(1318): DB_DataObject->_query("UPDATE civicrm_bank_tx_batch SET issue_date = 20191022115829 , reference = ...")
#11 /srv/www/d7-master/web/sites/all/modules/civicrm/CRM/Core/DAO.php(560): DB_DataObject->update()
#12 /srv/www/d7-master/web/sites/default/files/civicrm/ext/org.project60.banking/extension/CRM/Banking/PluginModel/Importer.php(282): CRM_Core_DAO->save()
#13 /srv/www/d7-master/web/sites/default/files/civicrm/ext/org.project60.banking/extension/CRM/Banking/PluginImpl/Importer/CSV.php(190): CRM_Banking_PluginModel_Importer->closeTransactionBatch(TRUE)
#14 /srv/www/d7-master/web/sites/default/files/civicrm/ext/org.project60.banking/extension/CRM/Banking/Page/Import.php(58): CRM_Banking_PluginImpl_Importer_CSV->import_file("/tmp/phpUbjg4e", (Array:2))
#15 /srv/www/d7-master/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(284): CRM_Banking_Page_Import->run((Array:3), NULL)
#16 /srv/www/d7-master/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#17 /srv/www/d7-master/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#18 /srv/www/d7-master/web/sites/all/modules/civicrm/drupal/civicrm.module(444): CRM_Core_Invoke::invoke((Array:3))
#19 /srv/www/d7-master/web/includes/menu.inc(527): civicrm_invoke("banking", "import")
#20 /srv/www/d7-master/web/index.php(21): menu_execute_active_handler()
#21 {main}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in sites/default/files/civicrm/ext/org.project60.banking/extension/CRM/Banking/PluginModel/Importer.php around line 282, where closeTransactionBatch saves the batch. Trace how the generated reference is assembled and how its database length is known; done means an oversized reference no longer causes the import to fail with a data-too-long error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100