BoltTranslate / Translate

Provides translation for contenttypes.
Other
43 stars 38 forks source link

[BUG] Two content types won't save after extension activated #75

Closed lswest closed 7 years ago

lswest commented 7 years ago

I've recently set up the translate extension on an upgraded site (from Bolt 2.2 to 3.0.12). I can add and save translations on all content types except two. The only difference between the content types that work, and those that don't, are hyphens. The two content types that don't work are ueber-uns, and content-marketing (defined exactly like that in the contenttypes.yml).

I admittedly haven't tried updating the posts since the upgrade to Bolt 3.0.12 without the translate extension active, but as the multilingual documentation page recommends hyphen usage, I figured I'd start here. In the backend, the only error message Bolt gives me is "Could not save Über Uns". I enabled the debug logging in Bolt, and tried to add a translation to a page under Über Uns, and included the error below.

Based off my understanding of MySQL, there should be quotes around the hyphenated column name, and I'm also uncertain why ueber-uns appears in the MySQL statement at all, as it doesn't exist in the table.

If there's any further information required, I'll be happy to pass it along.

Expected Outcome

Content is saved in the corresponding locale.

Actual Outcome

No changes are saved.

Details

These are the names of the column fields available in bolt_ueber_uns (the relevant table).

id slug datecreated datechanged datepublish datedepublish templatefields username ownerid status title body en_title en_slug de_data de_slug en_data locale

Error

The only relevant line I can find in the bolt-debug.log file is as follows: [2016-09-08 11:56:12] bolt.CRITICAL: Doctrine\DBAL\Exception\SyntaxErrorException: An exception occurred while executing 'SELECT ueber-uns.* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = ? LIMIT 1' with params ["1"]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 (uncaught exception) at /Users/lswest/Repositories/web-development/mbc-docker/data/site/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 90 {"exception":"[object] (Doctrine\\DBAL\\Exception\\SyntaxErrorException(code: 0): An exception occurred while executing 'SELECT ueber-uns.* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = ? LIMIT 1' with params [\"1\"]:\n\nSQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 at /Users/lswest/Repositories/web-development/mbc-docker/data/site/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:90, Doctrine\\DBAL\\Driver\\PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 at /Users/lswest/Repositories/web-development/mbc-docker/data/site/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93, PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 at /Users/lswest/Repositories/web-development/mbc-docker/data/site/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91)"} [] [2016-09-08 11:56:12] logger.system.CRITICAL: An exception occurred while executing 'SELECT ueber-uns.* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = ? LIMIT 1' with params ["1"]: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 {"event":"exception","exception":"[object] (Doctrine\\DBAL\\Exception\\SyntaxErrorException(code: 0): An exception occurred while executing 'SELECT ueber-uns.* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = ? LIMIT 1' with params [\"1\"]:\n\nSQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 at /Users/lswest/Repositories/web-development/mbc-docker/data/site/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:90, Doctrine\\DBAL\\Driver\\PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 at /Users/lswest/Repositories/web-development/mbc-docker/data/site/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93, PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = '1' LIMIT 1' at line 1 at /Users/lswest/Repositories/web-development/mbc-docker/data/site/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91)"} [] [2016-09-08 11:56:12] bolt.INFO: < 500 [] [] [2016-09-08 11:56:17] bolt.INFO: Matched route "fileedit". {"route_parameters":{"_controller":["[object] (Bolt\\Controller\\Backend\\FileManager: {})","edit"],"namespace":"config","zone":"backend","file":"config.yml","_route":"fileedit"},"request_uri":"http://mbc.home.lan/bolt/file/edit/config/config.yml?returnto=ajax"} [] [2016-09-08 11:56:17] bolt.INFO: > POST /bolt/file/edit/config/config.yml?returnto=ajax [] [] [2016-09-08 11:56:17] bolt.INFO: < 200 [] []

SvanteRichter commented 7 years ago

We have had a lot of issues with hyphens/underscores in bolt core lately, but this one is very odd since this query seems very wrong to me: SELECT ueber-uns.* FROM bolt_ueber_uns ueber-uns WHERE ueber-uns.id = ? LIMIT 1...

The general advice in all bolt projects currently is to not use underscores or hyphens in any keys or contenttype slugs until this issue is fully fixed though.

SvanteRichter commented 7 years ago

I'll look into this more when I got my normal internet back though :)

lswest commented 7 years ago

Thanks for the feedback. I've removed the hyphens, renamed the tables in MySQL, and then replaced the hyphens with underscores, and renamed the tables again (after each change, I also ran the database check, to update the structure). Now I can successfully translate the content types that were causing issues, and I haven't lost any data. I would prefer a hyphen in the URLs (especially for SEO and similar), but I can live with an underscore (which is, at least for the time being, much preferable to multiple words without spaces).

EDIT Turns out renaming just the content types didn't help. I had to specifically use underscores in the slug and singular_slug settings for the content type. After that, the hyphen was gone, and saving changes was working again. I would assume this is due to whatever system Bolt uses to generate slugs wanting to replace an underscore (and other special characters) with a hyphen.

SvanteRichter commented 7 years ago

@lswest Well, bolt generates the tablename from the slug unless you specify your own tablename with the tablename key. The contenttype key/name is actually just used to get the config, not for db stuff or slugs.

lswest commented 7 years ago

@SahAssar Thanks, I figured that out later in the day after browsing through the bolt/bolt bugs. I made my life easy, and simply cropped all contenttype names down to a single word. In the end, I may see about using routing to strip the slug entirely from the URL. I think you can mark this as closed, as it's not technically an issue with the extension (as far as I can tell).

Thanks for all the help!

SvanteRichter commented 7 years ago

Closing this, as it seems to be mostly the bolt issue, and partially our own which will be resolved soon, see #74