in2code-de / lux

Living User eXperience - LUX - the Marketing Automation tool for TYPO3.

Home Page:https://www.in2code.de/produkte/lux-typo3-marketing-automation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lux 27 DB Exception

rubensutter opened this issue · comments

I'm using TYPO3 11.5.24 with PHP 8.1.15.
I updated the lux extension (community edition) to release version 27.0.0.
After performing the update a click on the Backend Module "Leads" showed:

503
Oops, an error occurred!
An exception occurred while executing 'select distinct v.uid from tx_lux_domain_model_visitor v where v.deleted=0 and v.hidden=0 and v.identified=1 order by v.scoring DESC, v.tstamp DESC limit 10': Expression #1 of ORDER BY clause is not in SELECT list, references column '***.v.scoring' which is not in SELECT list; this is incompatible with DISTINCT

I guess in ext\lux\Classes\Domain\Repository VisitorRepository.php
line 188: $sql = 'select distinct v.uid from ' . Visitor::TABLE_NAME . ' v' ...
the select statement is missing ,v.scoring, v.tstamp in order to get the ORDER BY clause DISTINCT compatible?

/** * Find a small couple of hottest visitors * * @param FilterDto $filter * @param int $limit * @return array * @throws ExceptionDbal * @throws ExceptionDbalDriver */ public function findByHottestScorings(FilterDto $filter, int $limit = 10) { $connection = DatabaseUtility::getConnectionForTable(Visitor::TABLE_NAME); $sql = 'select distinct v.uid,v.scoring,v.tstamp from ' . Visitor::TABLE_NAME . ' v' . $this->extendFromClauseWithJoinByFilter($filter, ['pv', 'p', 'cs']) . ' where v.deleted=0 and v.hidden=0 and v.identified=1' . $this->extendWhereClauseWithFilterSearchterms($filter, 'v', 'email') . $this->extendWhereClauseWithFilterDomain($filter, 'pv') . $this->extendWhereClauseWithFilterScoring($filter, 'v') . $this->extendWhereClauseWithFilterCategoryScoring($filter, 'cs') . ' order by v.scoring DESC, v.tstamp DESC' . ' limit ' . $limit; $rows = $connection->executeQuery($sql)->fetchAllAssociative(); $results = []; foreach ($rows as $row) { $results[] = $this->findByUid($row['uid']); } return $results; }

Thx for your input, we will check this. Can you please write your MySQL or MariaDB version?

Thx, the MySQL versions are:
MySQL Ver 8.0.32 (local machine with TYPO3),
MySQL 10.3.37-MariaDB (on the TYPO3 webserver)

Thx, and the issue happens on both instances?

Strange, I can't reproduce the issue. Nevertheless, can you please try changing line 188 in VisitorRepository.php to:

$sql = 'select distinct v.uid, v.scoring, v.tstamp from ' . Visitor::TABLE_NAME . ' v'

and give me feedback?

The issue happened on he local machine.

I also tried to run the MySQL Query directly in MySQL on the local mysql Ver 8.0.32 (Linux on x86_64)
this also returned ... incompatible with DISTINCT

The server threw some errors more likely related to cache and autoloader and things like
Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1353170925: The relation information for property "pagevisits" of class "In2code\Lux\Domain\Model\Visitor" is missing. | TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidRelationConfigurationException thrown in file */sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php in line 983. Requested URL: *typo3/module/lux/LuxLead?token=--AnonymizedToken--

Now it's working fine with no errors, the Backend Lead Module shows all informations on both systems, local and server.
And the Lead Filter is working perfectly as well

I'm just a little unsure because of your sentence of "Some more errors...". Is the problem fixed with the change or do we have more challenges to solve? :)

Thx, as of now all errors are gone, everything is working great.

The Server is caching so it's not reacting to all changes immediately so I had to Flush the Caches, dump and have a look at the autoloader before all error messages dissapeared and the Module Content showed up as expected.
(with the change in VisitorRepository.php)

I'll also check lux version 27 with the TYPO3 12.2 running and post an update when finished

Update:
I just installed the lux 27 extension on a TYPO3 12.3 using PHP 8.1.2 with MySQL 8.0.32
(Windows 11 with WSL2 Linux Subsystem)
and got the same query 503 error so I think it's more likely related to MySQL Community Server 8.0.32
and the way it handles the DISTINCT ... ORDER BY queries.

Adding the v.scoring, v.tstamp to $sql solves it, the BE Lead Module loads with no errors and shows all panels and data.

Thx for the final feedback. We're going to release a 27.1.2 in a few minutes