Support OCI (Satisfy the CI)

This commit is contained in:
Austin Huang 2022-01-20 13:33:23 -05:00
parent 6a489d35ab
commit 041ef7f7a5
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
1 changed files with 15 additions and 12 deletions

View File

@ -200,8 +200,9 @@ class Database extends AbstractData
} }
try { try {
$big_string = $isVersion1 ? $paste['data'] : Json::encode($paste); $big_string = $isVersion1 ? $paste['data'] : Json::encode($paste);
$metajson = Json::encode($meta);
if (self::$_type === 'oci') { if (self::$_type === 'oci') {
# It is not possible to execute in the normal way if strlen($big_string) >= 4000 // It is not possible to execute in the normal way if strlen($big_string) >= 4000
$stmt = self::$_db->prepare( $stmt = self::$_db->prepare(
'INSERT INTO ' . self::_sanitizeIdentifier('paste') . 'INSERT INTO ' . self::_sanitizeIdentifier('paste') .
' VALUES(?,?,?,?,?,?,?,?,?)' ' VALUES(?,?,?,?,?,?,?,?,?)'
@ -212,7 +213,7 @@ class Database extends AbstractData
$stmt->bindParam(4, $expire_date, PDO::PARAM_INT); $stmt->bindParam(4, $expire_date, PDO::PARAM_INT);
$stmt->bindParam(5, $opendiscussion, PDO::PARAM_INT); $stmt->bindParam(5, $opendiscussion, PDO::PARAM_INT);
$stmt->bindParam(6, $burnafterreading, PDO::PARAM_INT); $stmt->bindParam(6, $burnafterreading, PDO::PARAM_INT);
$stmt->bindParam(7, Json::encode($meta)); $stmt->bindParam(7, $metajson);
$stmt->bindParam(8, $attachment, PDO::PARAM_STR, strlen($attachment)); $stmt->bindParam(8, $attachment, PDO::PARAM_STR, strlen($attachment));
$stmt->bindParam(9, $attachmentname); $stmt->bindParam(9, $attachmentname);
return $stmt->execute(); return $stmt->execute();
@ -251,7 +252,7 @@ class Database extends AbstractData
} }
self::$_cache[$pasteid] = false; self::$_cache[$pasteid] = false;
$rawData = ""; $rawData = '';
try { try {
$paste = self::_select( $paste = self::_select(
'SELECT * FROM ' . self::_sanitizeIdentifier('paste') . 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') .
@ -379,7 +380,7 @@ class Database extends AbstractData
} }
try { try {
if (self::$_type === 'oci') { if (self::$_type === 'oci') {
# It is not possible to execute in the normal way if strlen($big_string) >= 4000 // It is not possible to execute in the normal way if strlen($big_string) >= 4000
$stmt = self::$_db->prepare( $stmt = self::$_db->prepare(
'INSERT INTO ' . self::_sanitizeIdentifier('comment') . 'INSERT INTO ' . self::_sanitizeIdentifier('comment') .
' VALUES(?,?,?,?,?,?,?)' ' VALUES(?,?,?,?,?,?,?)'
@ -437,8 +438,7 @@ class Database extends AbstractData
' WHERE dataid = ?', array($id), true ' WHERE dataid = ?', array($id), true
); );
$rawData = self::_clob($newrow['DATA']); $rawData = self::_clob($newrow['DATA']);
} } else {
else {
$rawData = $row['data']; $rawData = $row['data'];
} }
$data = Json::decode($rawData); $data = Json::decode($rawData);
@ -719,7 +719,7 @@ class Database extends AbstractData
*/ */
private static function _getSemicolon() private static function _getSemicolon()
{ {
return self::$_type === 'oci' ? "" : ";"; return self::$_type === 'oci' ? '' : ';';
} }
/** /**
@ -980,15 +980,18 @@ class Database extends AbstractData
* *
* @access private * @access private
* @static * @static
* @param object $column * @param resource $column
* @return string * @return string
*/ */
private static function _clob($column) private static function _clob($column)
{ {
if ($column == null) return null; if ($column == null) {
$str = ""; return null;
while ($column !== null and $tmp = fread($column, 1024)) }
$str = '';
while ($tmp = fread($column, 1024)) {
$str .= $tmp; $str .= $tmp;
}
return $str; return $str;
} }
} }