aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-09-21 18:02:33 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-09-21 18:02:33 +0000
commit2ba402b06d69598c3ca068419441ef7270146fe3 (patch)
tree264dc3231c7e65488ce6fb277fddbd7f7cc24376 /phpBB
parent3d5ca6b2b715632206a7cd5d54548db5ef0230ce (diff)
downloadforums-2ba402b06d69598c3ca068419441ef7270146fe3.tar
forums-2ba402b06d69598c3ca068419441ef7270146fe3.tar.gz
forums-2ba402b06d69598c3ca068419441ef7270146fe3.tar.bz2
forums-2ba402b06d69598c3ca068419441ef7270146fe3.tar.xz
forums-2ba402b06d69598c3ca068419441ef7270146fe3.zip
And now i feel even more dirty because i had to adjust the oracle hack to allow for queries > 4k to let it recognise concatenated strings and strings having the character ")" in it. I also added fallback code in case our regex splits too much. :/
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10175 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/db/oracle.php51
1 files changed, 50 insertions, 1 deletions
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index 10f4a1a7a7..f7180029b5 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -255,13 +255,62 @@ class dbal_oracle extends dbal
// We overcome Oracle's 4000 char limit by binding vars
if (strlen($query) > 4000)
{
- if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/s', $query, $regs))
+ if (preg_match('/^(INSERT INTO[^(]++)\\(([^()]+)\\) VALUES[^(]++\\((.*?)\\)$/sU', $query, $regs))
{
if (strlen($regs[3]) > 4000)
{
$cols = explode(', ', $regs[2]);
+
preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER);
+ if (sizeof($cols) !== sizeof($vals))
+ {
+ // Try to replace some common data we know is from our restore script or from other sources
+ $regs[3] = str_replace("'||chr(47)||'", '/', $regs[3]);
+ $_vals = explode(', ', $regs[3]);
+
+ $vals = array();
+ $is_in_val = false;
+ $i = 0;
+ $string = '';
+
+ foreach ($_vals as $value)
+ {
+ if (strpos($value, "'") === false && !$is_in_val)
+ {
+ $vals[$i++] = $value;
+ continue;
+ }
+
+ if (substr($value, -1) === "'")
+ {
+ $vals[$i] = $string . (($is_in_val) ? ', ' : '') . $value;
+ $string = '';
+ $is_in_val = false;
+
+ if ($vals[$i][0] !== "'")
+ {
+ $vals[$i] = "''" . $vals[$i];
+ }
+ $i++;
+ continue;
+ }
+ else
+ {
+ $string .= (($is_in_val) ? ', ' : '') . $value;
+ $is_in_val = true;
+ }
+ }
+
+ if ($string)
+ {
+ // New value if cols != value
+ $vals[(sizeof($cols) !== sizeof($vals)) ? $i : $i - 1] .= $string;
+ }
+
+ $vals = array(0 => $vals);
+ }
+
$inserts = $vals[0];
unset($vals);