Conversation
a00e318 to
3eb87f1
Compare
3eb87f1 to
96320bf
Compare
96320bf to
1f9fcbe
Compare
| $this->assertFalse($result); | ||
| } | ||
|
|
||
| public function testRenameOversizedContainerFailsWhenNameIsStillTooLong(): void |
There was a problem hiding this comment.
And testRenameOversizedContainerFailsOnNameCollision() tests never make the container oversized, so renameOversizedContainer() returns early on "Container is not oversized". Neither the length check nor the collision check is actually exercised. Force the long name like in testRenameOversizedContainerSucceeds.
| return false; | ||
| } | ||
|
|
||
| $new_name = preg_replace('/[^\da-zA-Z]/', '', $new_name) ?? ''; |
There was a problem hiding this comment.
Digits are allowed here, but the "fix container names prior to 1.9.2" step (REGEXP \d+) will rename the container again on the next update. Could we reuse PluginFieldsToolbox::getSystemNameFromLabel() instead?
| * @param int $container_id Container ID. | ||
| * @param string[] $already_claimed Orphan tables already assigned to another itemtype in this call. | ||
| */ | ||
| private static function findOrphanTableForContainer(int $container_id, array $already_claimed): ?string |
There was a problem hiding this comment.
With several itemtypes, every orphan table has the same plugin_fields_containers_id default, so $by_default holds more than one entry, and the column fallback also finds several candidates. Nothing is recovered, and the message says "no existing data found". Also matching on the itemtype column default should fix it.
| // Disable oversized-table containers instead of crashing. | ||
| $obj = new self(); | ||
| $active_containers = $obj->find(['is_active' => 1]); | ||
| foreach ($active_containers as $container) { |
There was a problem hiding this comment.
This loop leaves disabled containers without a table, but preItemPurge() iterates over all containers regardless of is_active, so purging an item of that itemtype will throw a SQL error. Filter on is_active there, or skip class generation for oversized containers.
Checklist before requesting a review
Please delete options that are not relevant.
Description
plugins:fields:check_databasenow also reports container/item type pairs with no matching table, and tables with no matching container/item type pair.Screenshots (if appropriate):