Leave table names with numbers untouched in DatabaseBase::generalizeSQL
authorRohan <rohan1395@yahoo.com>
Sat, 19 Jul 2014 15:10:17 +0000 (20:40 +0530)
committerRohan <rohan1395@yahoo.com>
Sat, 19 Jul 2014 15:10:17 +0000 (20:40 +0530)
The function converts numbers to general forms
Eg. 10 => N
but creates a problem for tables whose names have digits in them
Eg. l10n_cache => lNn_cache

This was fixed using regex lookarounds

Bug: 67925
Change-Id: I0e97e211f6d60ba0d639b91d3a68c5e42bfb3f78

includes/db/Database.php

index 7d8fbe9..52222aa 100644 (file)
@@ -1769,9 +1769,10 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                # All newlines, tabs, etc replaced by single space
                $sql = preg_replace( '/\s+/', ' ', $sql );
 
-               # All numbers => N
+               # All numbers => N,
+               # except the ones surrounded by characters, e.g. l10n
                $sql = preg_replace( '/-?\d+(,-?\d+)+/s', 'N,...,N', $sql );
-               $sql = preg_replace( '/-?\d+/s', 'N', $sql );
+               $sql = preg_replace( '/(?<![a-zA-Z])-?\d+(?![a-zA-Z])/s', 'N', $sql );
 
                return $sql;
        }