Page MenuHomePhabricator

Error: ORA-00904: "ARRAY": invalid identifier with ORACLE (DatabaseOracle::doQuery)
Closed, ResolvedPublic

Description

Author: roy

Description:
It is possible to work your way through the web installer, but that's where the story ends.

Just about anything you do will result in:

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:
(SQL query hidden)
from within function "DatabaseOracle::doQuery". Database returned error "904: ORA-00904: "ARRAY": invalid identifier".

Reproduced on:

MediaWiki 1.20.2
PHP 5.3.14 (apache2handler)
Oracle 11.2.0.2.0


Version: 1.20.x
Severity: critical

Details

Reference
bz43533

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:13 AM
bzimport set Reference to bz43533.

roy wrote:

Problem does not exist in 1.19.3, I have not tried the previous 1.20.x releases.

freak wrote:

ARRAY??? where exactly are ARRAYs used?

roy wrote:

Apparently on line 1168 of htdocs/includes/db/DatabaseOracle.php

freak wrote:

?? in 1.19 that points to useIndexClause call whuch should ge DatabaseBase's return ''; function ... what's in your 1168 line of DatabaseOracle.php?

roy wrote:

In 1.20.2 it's

if ( isset( $options['GROUP BY'] ) ) {
                      $preLimitTail .= " GROUP BY {$options['GROUP BY']}";
              }
if ( isset( $options['ORDER BY'] ) ) {
                      $preLimitTail .= " ORDER BY {$options['ORDER BY']}";
              }

This code appears unchanged from 1.9.3, so I suppose the notice about array to string conversion (from the support desk report) must be unrelated to the actual problem.

roy wrote:

I tried a few different installations and was able to reproduce the problem in

  • 1.20.0
  • 1.20.1
  • 1.20.2

Problem does not exist in:

  • 1.19.3 and prior

roy wrote:

Actually, it looks like $preLimitTail is concatinated with "Array" after the conversion resulting in "ORDER BY Array" or "GROUP BY Array" in the final SQL.

I'm sure this is supposed to be replaced by the actual column name?

roy wrote:

Confirmed. Commenting out lines 1165 and 1168 works around the problem.

// $preLimitTail .= " GROUP BY {$options['GROUP BY']}";

I suppose there is another array inside $options['GROUP BY'] that should be imploded?

freak wrote:

yes i noticed ... somone changed the function in base and like usual 0FWG about the overloads. I'm fixing it ATM.

roy wrote:

Allright, here we go. I stole some code from includes/db/DatabasePostgres.php to implode the array before setting $preLimitTail.

[roy@lonora02 db]# diff DatabaseOracle.php DatabaseOracle.php.orig
1165,1167d1164
< $ob = is_array( $options['GROUP BY'] )
< ? implode( ',', $options['GROUP BY'] )
< : $options['GROUP BY'];
1171,1173d1167
< $ob = is_array( $options['ORDER BY'] )
< ? implode( ',', $options['ORDER BY'] )
< : $options['ORDER BY'];

freak wrote:

seems like this method overload is obsolete ... running phpunit test with it removed now.

roy wrote:

Oh, I missed a spot, $ob must be returned instead of $options['ORDER BY']:

[roy@lonora02 db]# diff DatabaseOracle.php DatabaseOracle.php.orig
1165,1168c1165
< $ob = is_array( $options['GROUP BY'] )
< ? implode( ',', $options['GROUP BY'] )
< : $options['GROUP BY'];

< $preLimitTail .= " GROUP BY {$ob}";

			$preLimitTail .= " GROUP BY {$options['GROUP BY']}";

1171,1174c1168
< $ob = is_array( $options['ORDER BY'] )
< ? implode( ',', $options['ORDER BY'] )
< : $options['ORDER BY'];

< $preLimitTail .= " ORDER BY {$ob}";

			$preLimitTail .= " ORDER BY {$options['ORDER BY']}";

I don't know the first thing about coding in php, but this worked for me :)

freak wrote:

current fixed in https://gerrit.wikimedia.org/r/#/c/41575/

has to be backported or you can just use the patch Roy suggested

The array maybe cames from gerrit 7521 and/or gerrit 22208

freak wrote:

no the array is from before that ... but i'm not always up to date with such changes as i just don't notice them, until something breaks ... liiiike now.

I'm assigning this bug to myself until i get the time to backport it to at least 1.20

(In reply to comment #15)

The array maybe cames from Gerrit change #7521 and/or Gerrit change #22208

Added array support for GROUP BY with HAVING and ORDER BY for all dbms with gerrit 45799