am-impact / amnav

Navigation plugin for Craft
168 stars 20 forks source link

SQL error when disabling an entry which is selected as a node in amnav #82

Closed kotyy closed 7 years ago

kotyy commented 8 years ago

Pardon me, but I haven't had a chance to test if this is reproducible in a fresh install or different version of Craft.

Craft 2.6.2911 amnav 1.7.4

To reproduce: Create an Entry. Add it as a node in amnav. Edit the entry and toggle OFF the Enabled setting. Save.

Error: CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'enabled' at row 1. The SQL statement executed was: UPDATEcraft_amnav_nodesSETenabled=:enabled,name=:name,dateUpdated=:dateUpdated WHEREid=:pC8vyaz8ZB. Bound with :pC8vyaz8ZB='16', :enabled=false, :name='Page NAme', :dateUpdated='2016-09-13 20:42:10'

tehatjamberry commented 7 years ago

I am experiencing the same issue: Craft 2.6.2955 AMNav 1.7.4

kblizeck commented 7 years ago

@kotyy Any word on this? Getting the same issue and need a fix!

kotyy commented 7 years ago

@kblizeck I haven't heard a word about it yet. So far, I've just worked around it, since it's a bit of edge case and doesn't cause anything to actually break.

tehatjamberry commented 7 years ago

@kblizeck Here are some workarounds:

You can always delete the menu item in AMNav which breaks the entry relationship.

We've been able to work around it by leaving the entries' enabled/disabled-toggle enabled and setting the post date in the future to disable the entry (You just have to remember to toggle the menu item off in AMNav manually otherwise you'll have a menu item going to a disabled page)

We're also using locales so there is an additional per-locale enabled/disabled switch that we've been able to switch off while leaving the global enable/disable switch enabled.

screenshot_25

You can also build manual (My Own) menu items that don't have the entry relationship. (Again, you'll have to manage the menu item enabled/disabled manually)


About the issue:

The issue is that the query being built is trying to execute enabled=true|false while the database column is expecting to write enabled=1|0. I haven't looked under the hood enough, nor understand all the inner-working of how Craft Plugin models assemble queries to know what the proper fix is.

Hope this helps.