-
Notifications
You must be signed in to change notification settings - Fork 889
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
[Bug] Potential issue saving a reorder when the model relies on a different database outside of the set default #5656
Comments
Hello there! Thanks for opening your first issue on this repo! Just a heads-up: Here at Backpack we use GitHub Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that. Backpack communication channels:
Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch. Thank you! -- |
Hey @SilverFocus Sorry for the inconvenience. I'm assigning the issue to my colleague to fix it. Thanks for reporting. @pxpm What I did to test:
|
Hello - a follow-up here! I noticed maybe one other potential issue some people might hit. Casting the Primary Key (PK) as an int in Reorder.php will also cause the reorder to fail if the PK is not actually a INT for that database column. I say this because a PK on one of my reorderable models is actually a varchar and the reorder was still breaking. Changing line 32 from: |
Thanks @SilverFocus for the heads up 👍 I've just merged the fix and will be available in the next patch release. 🙏 Cheers |
Bug report
What I did
I clicked to reorder items, then clicked save on the reorder page.
What I expected to happen
The reorder to save properly.
What happened
Upon saving:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'franchise_local.staff_bios' doesn't exist (Connection: mysql, SQL: UPDATE staff_bios SET parent_id = CASE WHEN id = 97 THEN ? WHEN id = 39 THEN ? WHEN id = 37 THEN ? ELSE parent_id END WHERE id IN (37,39,97))
I have 2 databases:
The reorder is attempting to save to the wrong database and table entirely, it should be
franchise_global.staff_bios
- this was not an issue for me at all until I migrated over to Backpack 6.I have a connection property set on my staff_bios model that specifies the global database and any other CRUD actions work perfectly fine on this model. It seems to be ignoring the connection property completely when saving the reorder, which is reflected by how it attempts to save it to
franchise_local.staff_bios
- which is a table that does not exist in that local database. I have another model for promotions, also uses reorder, that is also having this same exact issue.Additionally, I have another model with rorder for nav menus that exist in these local databases, and the reorder works 100% fine here.
I do not use github a ton, so I apologize if the format is messy in anyway or this does not make sense.
CRUD:
Model:
What I've already tried to fix it
If there is an issue, I think it might reside in
updateTreeOrder()
inbackpack/crud/src/app/Library/CrudPanel/Traits/Reorder.php
where $query is being set with$this->model->getTable()
Ultimately, I want to know if it's a 'me' issue in forgetting to change something when migrating from backpack 5 to 6 , because I'm stumped at this point.
Is it a bug in the latest version of Backpack?
After I run
composer update backpack/crud
the bug... is it still there?Yes, this issue started happening after I moved from Backpack 5 to Backpack 6.
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:PHP VERSION:
8.2.22
PHP EXTENSIONS:
Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, readline, Reflection, SPL, session, standard, bcmath, calendar, ctype, curl, dom, fileinfo, ftp, gd, iconv, imap, mbstring, mysqlnd, PDO, Phar, posix, SimpleXML, sockets, sqlite3, tokenizer, xml, xmlwriter, xsl, zip, mysqli, pdo_mysql, pdo_sqlite, xmlreader
LARAVEL VERSION:
11.22.0.0
BACKPACK PACKAGE VERSIONS:
backpack/basset: 1.3.6
backpack/crud: 6.7.34
backpack/filemanager: 3.0.8
backpack/generators: v4.0.6
backpack/menucrud: v4.0.2
backpack/newscrud: 5.1.0
backpack/pagemanager: 3.3.1
backpack/permissionmanager: 7.2.1
backpack/pro: 2.2.15
backpack/revise-operation: 2.0.0
backpack/theme-coreuiv2: 1.2.5
The text was updated successfully, but these errors were encountered: