500 error when removing contacts from campaign

Your software
My Mautic version is: 2.15.3
My PHP version is: 7.2.23

Your problem
My problem is: When trying to remove some contacts from a campaign, I’m getting a 500 error.

These errors are showing in the log:

[2019-10-13 08:28:22] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\SyntaxErrorException: "An exception occurred while executing 'REPLACE INTO mauag_campaign_lead_event_failed_log( log_id, date_added, reason) SELECT id, :dateAdded as date_added, :message as reason from mauag_campaign_lead_event_log WHERE is_scheduled = 1 AND lead_id = :contactId AND campaign_id = :campaignId AND rotation = :rotation': 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 ':dateAdded as date_added, :message as reason from mauag_campaign_lead_event_log ' at line 2" at /home/misbolet/marketing.angelsguitar.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 90 {"exception":"[object] (Doctrine\\DBAL\\Exception\\SyntaxErrorException(code: 0): An exception occurred while executing 'REPLACE INTO mauag_campaign_lead_event_failed_log( log_id, date_added, reason)\nSELECT id, :dateAdded as date_added, :message as reason from mauag_campaign_lead_event_log\nWHERE is_scheduled = 1 AND lead_id = :contactId AND campaign_id = :campaignId AND rotation = :rotation':\n\nYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':dateAdded as date_added, :message as reason from mauag_campaign_lead_event_log\n' at line 2 at /home/misbolet/marketing.angelsguitar.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:90, Doctrine\\DBAL\\Driver\\Mysqli\\MysqliException(code: 0): 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 ':dateAdded as date_added, :message as reason from mauag_campaign_lead_event_log\n' at line 2 at /home/misbolet/marketing.angelsguitar.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php:101)"} []

Steps I have tried to fix the problem:

Tried to update database schema, but also shows an error and is unable to complete.

Hi there,

Give this a go:

Click on the … … … … … … … … … … … down arrow to expand and make it readable here. :arrow_down:

Hi @virgilwashere, Thanks for your reply.

I followed the recommendations, including clearing the cache and checking the database’s status. Seems that the database is in-sync:

[misbolet@spro4 app]$ php console doctrine:schema:update
Nothing to update - your database is already in sync with the current entity metadata.

However, I’m still getting the 500 error when trying to select several contacts and removing them from a campaign. Also, Mautic won’t allow me to turn off a campaign by directly editing a contact.

I did notice there are still migrations reported:

>> Available Migrations:                               134
    >> New Migrations:                                     31

I’m quite new at Mautic so I’m not sure how to proceed in this case.

Run migrations

dry run first

$ console doctrine:migrations:migrate --allow-no-migration --query-time --dry-run

                    Mautic Migrations

Executing dry run of migration up to 20190715065013 from 20190715065013

  ++ migrating 20190704154940


  ++ migrated (0.5s)

  ------------------------

  ++ finished in 0.5s
  ++ 1 migrations executed
  ++ 0 sql queries

real version

Swap --dry-run for --no-interaction

$ console doctrine:migrations:migrate --allow-no-migration --query-time --no-interaction
[2019-10-19 14:56:40]
[2019-10-19 14:56:40]                     Mautic Migrations
[2019-10-19 14:56:40]

[2019-10-19 14:56:40] Migrating up to 20190715065013 from 20190715065013
[2019-10-19 14:56:40]
  ++ migrating 20190704154940

[2019-10-19 14:56:41] Migration 20190704154940 was executed but did not result in any SQL statements.
[2019-10-19 14:56:41]
  ++ migrated (0.59s)
[2019-10-19 14:56:41]
  ------------------------

[2019-10-19 14:56:41]   ++ finished in 0.59s
[2019-10-19 14:56:41]   ++ 1 migrations executed
[2019-10-19 14:56:41]   ++ 0 sql queries

Good luck!

Regards,

Virgil
:australia:

Hi @virgilwashere.

I’m getting this after swapping --dry-run for --no-interaction:

[2019-10-23 02:04:03]
[2019-10-23 02:04:03]                     Mautic Migrations
[2019-10-23 02:04:03]

[2019-10-23 02:04:03] Migrating up to 20190715065013 from 20180220212444
[2019-10-23 02:04:03]
  ++ migrating 20180329185634

[2019-10-23 02:04:03]      -> ALTER TABLE mauek_lead_event_log DROP FOREIGN KEY FK_EF546E0855458D
[2019-10-23 02:04:03] Migration 20180329185634 failed during Execution. Error An exception occurred while executing 'ALTER TABLE mauek_lead_event_log DROP FOREIGN KEY FK_EF546E0855458D':

Can't DROP 'FK_EF546E0855458D'; check that column/key exists


  [Doctrine\DBAL\Exception\DriverException]
  An exception occurred while executing 'ALTER TABLE mauek_lead_event_log DROP FOREIGN KEY FK_EF546E0855458D':

  Can't DROP 'FK_EF546E0855458D'; check that column/key exists



  [Doctrine\DBAL\Driver\Mysqli\MysqliException]
  Can't DROP 'FK_EF546E0855458D'; check that column/key exists

How should I proceed in this case?

The migration task wants to remove something that is’nt there.
You haven’t by chance installed with Softaculous have you?

Because the “solution” is to create the foreign key it’s looking for …

And I’d suggest using this SQL admin web interface if you don’t have one already setup.

https://www.adminer.org/latest-mysql-en.php
save it as adminer.php

Virgil

1 Like

Yes, I used Softaculous. Seems like it wasn’t a good idea :confused:

I do have PHPMyAdmin. However, I tried to follow the GitHub link you shared, but I’m getting this when executing the query:

#1452 - Cannot add or update a child row: a foreign key constraint fails...

Not sure what I might be doing wrong.

I’m experiencing the same error. I also initially installed on Softaculous.

If I install the next update directly, do you think that will fix the situation or is the missing piece from the Softaculous install always going to be missing?