putyourlightson / craft-campaign

Send and manage email campaigns, contacts and mailing lists in Craft CMS.
https://putyourlightson.com/plugins/campaign
Other
63 stars 25 forks source link

SQL error: Unknown column 'title' in 'order clause' #469

Closed arifje closed 7 months ago

arifje commented 7 months ago

Bug Report

I am getting an SQL error when displaying some mailing lists in the users profile page, caused by getMailingLists() function;

Snippet of my code;

{% set userContact = craft.campaign.contacts.userId(currentUser.id).one() %}
{% set userMailingLists = userContact ? userContact.getMailingLists() : [] %}

Error:

Database Exception – [yii\db\Exception](https://www.yiiframework.com/doc-2.0/yii-db-exception.html)
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'title' in 'order clause'
The SQL being executed was: SELECT `mailingListId`
FROM (SELECT `campaign_contacts_mailinglists`.*
FROM `campaign_contacts_mailinglists`
INNER JOIN `elements` `contactElement` ON `contactElement`.`id` = `contactId`
INNER JOIN `elements` `mailingListElement` ON `mailingListElement`.`id` = `mailingListId`
WHERE (`contactElement`.`draftId` IS NULL) AND (`contactElement`.`dateDeleted` IS NULL) AND (`mailingListElement`.`dateDeleted` IS NULL)) `subquery`
WHERE `contactId`=40332
ORDER BY `title`
Screenshot 2024-04-20 at 20 54 14

Plugin Version

2.15.1

Craft CMS Version

4.8.9

PHP Version

No response

bencroker commented 7 months ago

Thanks for reporting this. Fixed in https://github.com/putyourlightson/craft-campaign/commit/3ea883d75e0992c899d5f05859ecc7dde977c990 for the next release.

bencroker commented 6 months ago

Released in 2.15.2.