terminal42 / contao-url-rewrite

Provides a back end module in Contao that allows you to specify url rewrites that are added to the Symfony Route collection
MIT License
15 stars 4 forks source link

Can't create a new url rewrite rule #5

Closed dmolineus closed 6 years ago

dmolineus commented 6 years ago

Just wanted to give this extension a try, but I fail creating an url rewrite. I get following exception using it in Contao 4.4.13 managed edition:

An exception occurred while executing 'INSERT INTO tl_url_rewrite (`type`, `responseCode`, `tstamp`) VALUES ('basic', 301, 0)':

SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value

Stacktrace

Doctrine\DBAL\Exception\NotNullConstraintViolationException:
An exception occurred while executing 'INSERT INTO tl_url_rewrite (`type`, `responseCode`, `tstamp`) VALUES ('basic', 301, 0)':

SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value

  at vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:118
  at Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception occurred while executing \'INSERT INTO tl_url_rewrite (`type`, `responseCode`, `tstamp`) VALUES (\'basic\', 301, 0)\':SQLSTATE[HY000]: General error: 1364 Field \'name\' doesn\'t have a default value', object(PDOException))
     (vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:176)
  at Doctrine\DBAL\DBALException::wrapException(object(Driver), object(PDOException), 'An exception occurred while executing \'INSERT INTO tl_url_rewrite (`type`, `responseCode`, `tstamp`) VALUES (\'basic\', 301, 0)\':SQLSTATE[HY000]: General error: 1364 Field \'name\' doesn\'t have a default value')
     (vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:150)
  at Doctrine\DBAL\DBALException::driverExceptionDuringQuery(object(Driver), object(PDOException), 'INSERT INTO tl_url_rewrite (`type`, `responseCode`, `tstamp`) VALUES (\'basic\', 301, 0)', array())
     (vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:915)
  at Doctrine\DBAL\Connection->executeQuery('INSERT INTO tl_url_rewrite (`type`, `responseCode`, `tstamp`) VALUES (\'basic\', 301, 0)')
     (vendor/contao/core-bundle/src/Resources/contao/library/Contao/Database/Statement.php:284)
  at Contao\Database\Statement->query()
     (vendor/contao/core-bundle/src/Resources/contao/library/Contao/Database/Statement.php:257)
  at Contao\Database\Statement->execute()
     (vendor/contao/core-bundle/src/Resources/contao/drivers/DC_Table.php:682)
  at Contao\DC_Table->create()
     (vendor/contao/core-bundle/src/Resources/contao/classes/Backend.php:629)
  at Contao\Backend->getBackendModule('url_rewrites', null)
     (vendor/contao/core-bundle/src/Resources/contao/controllers/BackendMain.php:135)
  at Contao\BackendMain->run()
     (vendor/contao/core-bundle/src/Controller/BackendController.php:55)
  at Contao\CoreBundle\Controller\BackendController->mainAction()
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:202)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (web/app_dev.php:64)
qzminski commented 6 years ago

@Toflar this is again the SQL in strict mode problem... I guess we should just provide a default value for our fields?

dmolineus commented 6 years ago

Additional note: I fixed the first issue by adding the default value for my own. But the next error occurs with the redirectHosts field (blob). Adding a default value null doesn't make any difference. Though I guess this might be a Contao issue then.

Toflar commented 6 years ago

I think adding the default values is good practice anyway. Do you mind contributing what you added on your own already?

dmolineus commented 6 years ago

Well, I only added two default values and realized that it doesn't solve the issue for me and I stopped working on it because of lack of time. For my current use case some custom controllers work pretty well at the moment.

So I can't promise a contribution.

qzminski commented 6 years ago

Fixed in 3fe9c4a. @Toflar shall I release 1.1.1 now?

Toflar commented 6 years ago

Sure, there's no reason to hold back hotfixes :)