eveseat / seat

🌀✳️ SeAT: A Simple, EVE Online API Tool and Corporation Manager
https://eveseat.github.io/docs/
GNU General Public License v2.0
425 stars 143 forks source link

Squad Filters - Title Search #821

Open SimplyUnnamed opened 2 years ago

SimplyUnnamed commented 2 years ago

Problem: Searching title returns Server 500 error,

exception: "ErrorException"
file: "/var/www/seat/vendor/eveseat/web/src/Http/Controllers/Support/FastLookupController.php"
line: 129
message: "Trying to get property 'name' of non-object"
| Vendor   | Package Name           | Installed Version        |
| -------- | ---------------------- | ------------------------ |
| eveseat  | api                    | 4.5.0                    |
| eveseat  | console                | 4.8.0                    |
| eveseat  | eveapi                 | 4.11.2                   |
| eveseat  | notifications          | 4.3.1                    |
| eveseat  | services               | 4.2.0                    |
| eveseat  | web                    | 4.12.2                   |
| denngarr | seat-fitting           | 4.0.5                    |
| denngarr | seat-srp               | 4.2.6                    |
| warlof   | seat-connector         | 2.3.0                    |
| warlof   | seat-discord-connector | 5.0.0                    |
| ccp      | eve_online_sde         | sde-20210713-TRANQUILITY |

Issue is dependent on what is search. Ie. I can search for 'Officer' title, but searching 'Director' will throw and error.

Issue also occurs on the initial search with a blank string.

warlof commented 2 years ago

It sounds like a database integrity issue. I think you have titles which are referencing corporation that didn't exist.

Can you give the output of that query ?

SELECT COUNT(*)
FROM corporation_titles
WHERE corporation_id NOT IN (SELECT corporation_id FROM corporation_infos);
SimplyUnnamed commented 2 years ago

ahh, I see.

there are 28 corps missing. this makes sense.

warlof commented 2 years ago

Not necesarrly 28 corp, the upper query is only listing amount of titles tied to an orphan corp. You also can have 28 titles not linked to the same corp.

I had to figure if yes or no that pivot table should have a foreign key. I think character module is using it.

SimplyUnnamed commented 2 years ago

doesn't look like the corporation titles has a foreign key, but it is indexed. This is from an update of a SeAT 3 instance, so maybe there was a migration that disappeared or didn't get run.

But it makes sense that this is because there is missing corps in corporation_infos table as there's not requirements in the CorporationTitles query that the record exists. its just assumed and eager loaded, and the corporation name is accessed regardless.

warlof commented 2 years ago

It is not, this is how the database is currently structured 😊

resixh commented 2 years ago

what was the fix for this?

resixh commented 2 years ago

MariaDB [seat]> SELECT COUNT() -> FROM corporation_titles -> WHERE corporation_id NOT IN (SELECT corporation_id FROM corporation_infos); +----------+ | COUNT() | +----------+ | 1 | +----------+ 1 row in set (0.001 sec)