Skip to content
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

Can $hasTags include a database column check? #524

Open
solonmedia opened this issue Mar 24, 2024 · 0 comments
Open

Can $hasTags include a database column check? #524

solonmedia opened this issue Mar 24, 2024 · 0 comments

Comments

@solonmedia
Copy link

Short description of the enhancement

When creating fields programmatically that use the tags feature (FieldtypeImage, FieldtypeFile) for some reason the schema database update doesn't seem to check whether the column actually exists in the field table or not.

This shows up when trying to create a field in RockMigrations where the 'useTags' setting > 0.

The issue is that the correct SQL appears in the schema when you return

$fieldtypes->FiletypeFile->getDatabaseSchema

but the updateDatabaseSchema call that follows seems to detect that the table already has tags

via:

https://github.com/processwire/processwire/blob/3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7/wire/modules/Fieldtype/FieldtypeFile/FieldtypeFile.module#L1164

and so the structure of the table is not altered.

When you try to access saved field data, the inputfield value throws an error because field_name.tags column doesn't exist.

Current vs. suggested behavior

I am thinking the $hasTags declaration perhaps needs another sanity check on the DB to be sure the tags column really exists if it is defined in the schema?

Why would the enhancement be useful to users?

This would allow modules like RockMigrations to create fields with the useTags option (Image and File). Right now this is not possible simply by includes 'useTags' => 1 in the field settings array.

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

No branches or pull requests

1 participant