Project

General

Profile

Actions

Bug #72039

closed

Exception when trying to open a translated page in frontend when using PostgreSQL

Added by Lars Peter Søndergaard almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2015-12-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

This is the following exception I get:

Uncaught TYPO3 Exception
#1310027511: Could not parse where clause (More information)

InvalidArgumentException thrown in file
/var/www/pgsql/typo3_src-build/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php in line 1753.

30 TYPO3\CMS\Dbal\Database\DatabaseConnection::quoteWhereClause("pid = '1' AND colPos = '0' AND tt_content.deleted=…1', CAST("tt_content"."fe_group" AS CHAR)) != 0)))")

/var/www/pgsql/typo3_src-build/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php:
01263:         $select_fields = $this->quoteFieldNames($select_fields);
01264:         $from_table = $this->quoteFromTables($from_table);
01265:         $where_clause = $this->quoteWhereClause($where_clause);
01266:         $groupBy = $this->quoteGroupBy($groupBy);
01267:         $orderBy = $this->quoteOrderBy($orderBy);

29 TYPO3\CMS\Dbal\Database\DatabaseConnection::SELECTquery("*", "tt_content", "pid = '1' AND colPos = '0' AND tt_content.deleted=…1', CAST("tt_content"."fe_group" AS CHAR)) != 0)))", "", "sorting ASC")

/var/www/pgsql/typo3_src-build/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php:
00847:                         $this->lastQuery = $this->SELECTqueryFromArray($remappedParameters);
00848:                     } else {
00849:                         $this->lastQuery = $this->SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy);
00850:                     }
00851:                     $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_Execute($this->lastQuery);

28 TYPO3\CMS\Dbal\Database\DatabaseConnection::exec_SELECTquery("*", "tt_content", "pid = '1' AND colPos = '0' AND tt_content.deleted=…1', CAST("tt_content"."fe_group" AS CHAR)) != 0)))", "", "sorting ASC", NULL)

/var/www/pgsql/typo3_src-build/typo3/sysext/core/Classes/Database/DatabaseConnection.php:
00375:     public function exec_SELECTgetRows($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy = '', $limit = '', $uidIndexField = '')
00376:     {
00377:         $res = $this->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit);
00378:         if ($this->sql_error()) {
00379:             $this->sql_free_result($res);

27 TYPO3\CMS\Core\Database\DatabaseConnection::exec_SELECTgetRows("*", "tt_content", "pid = '1' AND colPos = '0' AND tt_content.deleted=…1', CAST("tt_content"."fe_group" AS CHAR)) != 0)))", "", "sorting ASC", NULL)

[…]

\TYPO3\CMS\Dbal\Database\DatabaseConnection::quoteWhereClause calls \TYPO3\CMS\Dbal\Database\SqlParser::parseWhereClause which returns a string instead of an array: 'No ) parenthesis at end of subquery'.

The where clause that's being parsed is the following, which does not actually seem to have any parenthesis errors:

pid = '1' 
AND colPos = '0' 
AND tt_content.deleted=0 
AND tt_content.t3ver_state<=0 
AND tt_content.pid<>-1 
AND tt_content.hidden=0 
AND tt_content.starttime<=1449133200 
AND (tt_content.endtime=0 OR tt_content.endtime>1449133200) 
AND (tt_content.fe_group='' OR tt_content.fe_group IS NULL OR tt_content.fe_group='0' OR FIND_IN_SET('0',tt_content.fe_group) OR FIND_IN_SET('-1',tt_content.fe_group))
AND (sys_language_uid IN (-1,1) AND uid NOT IN
  (SELECT "l18n_parent" FROM "tt_content" WHERE   
   "sys_language_uid" = 1 
   AND  "tt_content"."deleted" = 0 
   AND  "tt_content"."t3ver_state" <= 0 
   AND  "tt_content"."pid" <> -1 
   AND  "tt_content"."hidden" = 0 
   AND  "tt_content"."starttime" <= 1449133200 
   AND ("tt_content"."endtime" = 0 OR  "tt_content"."endtime" > 1449133200) 
   AND ("tt_content"."fe_group" = '' OR  "tt_content"."fe_group" IS NULL OR  "tt_content"."fe_group" = '0' 
        OR   FIND_IN_SET('0', CAST("tt_content"."fe_group" AS CHAR)) != 0 
        OR   FIND_IN_SET('-1', CAST("tt_content"."fe_group" AS CHAR)) != 0
   )
  )
)

Files

pgsql.localhost - translated page exception.html (31.5 KB) pgsql.localhost - translated page exception.html Full Traceback Lars Peter Søndergaard, 2015-12-04 11:24
Actions #1

Updated by Lars Peter Søndergaard almost 9 years ago

Forgot to add, even though the title somewhat states it and even though the error does not seem to be related to translations in general:

Steps to reproduce:

- I created a new page and translated it to another language.
- I opened the page in frontend and added &L=1 to the URL

--

Also happens with very simple queries:

$where = 'foo IN (SELECT * FROM foobar)';
$x = $where;  // copy because parseWhereClause takes query as reference
$parsed = $GLOBALS['TYPO3_DB']->SQLparser->parseWhereClause($x);
DebuggerUtility::var_dump([$parsed, $where]);

Output:
array(2 items)
   0 => 'No ) parenthesis at end of subquery' (35 chars)
   1 => 'foo IN (SELECT * FROM foobar)' (29 chars)
Actions #2

Updated by Morton Jonuschat almost 9 years ago

  • Status changed from New to Needs Feedback

I tried to reproduce according to the given steps but the page seems to work in Frontend and Backend in both languages. The source of the problem seems to be that the query for the subselect already has been parsed and quoted for PostgreSQL but the outer query has not. I can't seem to track down where that could happen. Are you able to provide the full stacktrace (probably best as an attachment) and maybe give some information if there are any 3rd party/plugin content elements on your page that could trigger this?

Actions #3

Updated by Lars Peter Søndergaard almost 9 years ago

Traceback as attachment.

In that project I use fluid_styled_content and vhs.

Additionally a custom extension that contains all the typoscript configuration.

The templates typoscript looks like this:

# Fluid Template
lib.fluidTemplate = FLUIDTEMPLATE
lib.fluidTemplate {
    partialRootPath = EXT:lfmtheme/Resources/Private/LFM/Partials/
    layoutRootPath  = EXT:lfmtheme/Resources/Private/LFM/Layouts/

    settings {
        mainmenu = {$plugin.tx_lfmtheme.settings.mainmenu}
    }
}

# Fluid Layout
lib.fluidLayout = CASE
lib.fluidLayout {
    key.data = pagelayout
    default = TEXT
    default.value = Bitte Backendlayout auswählen

    pagets__oneColumnTemplate < lib.fluidTemplate
    pagets__oneColumnTemplate.file = EXT:lfmtheme/Resources/Private/LFM/Templates/OneColumn.html

    pagets__twoColumnTemplate < lib.fluidTemplate
    pagets__twoColumnTemplate.file = EXT:lfmtheme/Resources/Private/LFM/Templates/TwoColumn.html
}

# ... and later:
page.10 < lib.fluidLayout

Backendlayouts are defined in TSConfig files.

The respective HTML files are simple fluid templates, that use vhs' v:content.render to render specific columns.

<html xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers" 
      xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" 
      data-namespace-typo3-fluid="true">

<f:layout name="Default"/>

<f:section name="Main">
    <div class="col-xs-12 col-md-8">
        <f:if condition="{v:content.get(column:0)}">
            <v:content.render column="0"/>
        </f:if>
    </div>
    <div class="col-xs-12 col-md-4">
        <v:content.render column="1"/>
    </div>
</f:section>

I don't think there is anything abnormal here, but that's not for me to judge :-)

Actions #4

Updated by Morton Jonuschat almost 9 years ago

  • Status changed from Needs Feedback to Closed

Thanks for the stack trace. This is actually triggered by the getContent ViewHelper from EXT:vhs

The source is https://github.com/FluidTYPO3/vhs/blob/development/Classes/ViewHelpers/Content/AbstractContentViewHelper.php#L111

This construct - when used with DBAL - leads to the situation that the subselect ($nestedQuery) is already parsed and quoted for the DBMS and the outer query has not yet been parsed and rewritten. This leads to a combination of unparsed and parsed SQL fragments which cannot be rewritten anymore. In this us case it would probably be easiest not to use SELECTquery to build the simple subselect.

Actions

Also available in: Atom PDF