diff -urpN drupal-6.x-dev-200707090006/includes/cache.inc drupal-6.x-dev-clob-0.4/includes/cache.inc --- drupal-6.x-dev-200707090006/includes/cache.inc 2007-05-26 05:01:30.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/includes/cache.inc 2007-07-09 10:58:14.000000000 +0800 @@ -105,10 +105,11 @@ function cache_set($cid, $data, $table = $serialized = 1; } $created = time(); - db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, $created, $expire, $headers, $serialized, $cid); + db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", NULL, $created, $expire, $headers, $serialized, $cid); if (!db_affected_rows()) { - @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, $created, $expire, $headers, $serialized); + @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, NULL, $created, $expire, $headers, $serialized); } + db_update_blob('{' . $table . '}', array('data' => $data), "cid = '%s'", $cid); } /** diff -urpN drupal-6.x-dev-200707090006/includes/database.inc drupal-6.x-dev-clob-0.4/includes/database.inc --- drupal-6.x-dev-200707090006/includes/database.inc 2007-07-02 22:41:35.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/includes/database.inc 2007-07-11 18:18:10.000000000 +0800 @@ -158,6 +158,9 @@ function db_set_active($name = 'default' /** * Helper function for db_query(). + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). */ function _db_query_callback($match, $init = FALSE) { static $args = NULL; @@ -175,15 +178,17 @@ function _db_query_callback($match, $ini return '%'; case '%f': return (float) array_shift($args); - case '%b': // binary data - return db_encode_blob(array_shift($args)); + case '%b': // binary large object. NULL input as placeholder. + return db_encode_blob(array_shift($args)); + case '%c': // character large object. NULL input as placeholder. + return db_encode_clob(array_shift($args)); } } /** * Indicates the place holders that should be replaced in _db_query_callback(). */ -define('DB_QUERY_REGEXP', '/(%d|%s|%%|%f|%b)/'); +define('DB_QUERY_REGEXP', '/(%d|%s|%%|%f|%b|%c)/'); /** * Helper function for db_rewrite_sql. diff -urpN drupal-6.x-dev-200707090006/includes/database.mysql-common.inc drupal-6.x-dev-clob-0.4/includes/database.mysql-common.inc --- drupal-6.x-dev-200707090006/includes/database.mysql-common.inc 2007-06-27 04:24:19.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/includes/database.mysql-common.inc 2007-07-11 18:11:41.000000000 +0800 @@ -27,7 +27,7 @@ * you may also pass a single array containing the query arguments. * * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -217,6 +217,9 @@ function db_type_map() { 'blob:big' => 'LONGBLOB', 'blob:normal' => 'BLOB', + 'clob:big' => 'LONGTEXT', + 'clob:normal' => 'TEXT', + 'datetime:normal' => 'DATETIME', ); return $map; @@ -462,7 +465,104 @@ function db_last_insert_id($table, $fiel } /** + * Update Character Large Object value. Wrapper function for _db_update_lob() + * + * @param $table + * Table to update. + * @param $values + * Values to update, in array format. Columns and values pairs. + * @param $where + * Update condition. + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @return + * Returns TRUE on success or FALSE on failure. + */ +function db_update_blob($table, $values, $where) { + $args = func_get_args(); + array_shift($args); + array_shift($args); + array_shift($args); + $args = is_array($args) ? $args : array($args); + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + return _db_update_lob($table, $values, $where, $args, 'BLOB'); +} + +/** + * Update Binary Large Object value. Wrapper function for _db_update_lob() + * + * @param $table + * Table to update. + * @param $values + * Values to update, in array format. Columns and values pairs. + * @param $where + * Update condition. + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @return + * Returns TRUE on success or FALSE on failure. + */ +function db_update_clob($table, $values, $where) { + $args = func_get_args(); + array_shift($args); + array_shift($args); + array_shift($args); + $args = is_array($args) ? $args : array($args); + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + return _db_update_lob($table, $values, $where, $args, 'CLOB'); +} + +/** + * Helper function for update Large Object value. + */ +function _db_update_lob($table, $values, $where, $args, $lobtype = 'BLOB') { + _db_query_callback($args, TRUE); + $where = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $where); + + $arr = array(); + foreach ($values as $key => $value) { + switch ($lobtype) { + case 'BLOB': $arr[] = $key . " = " . db_encode_blob($value); break; + case 'CLOB': $arr[] = $key . " = " . db_encode_clob($value); break; + } + } + + $query = 'UPDATE ' . db_prefix_tables($table) . ' SET ' . implode(', ', $arr) . ' WHERE ' . $where; + return _db_query($query); +} + +/** * @} End of "ingroup schemaapi". */ -?> \ No newline at end of file +?> diff -urpN drupal-6.x-dev-200707090006/includes/database.mysqli.inc drupal-6.x-dev-clob-0.4/includes/database.mysqli.inc --- drupal-6.x-dev-200707090006/includes/database.mysqli.inc 2007-06-05 20:13:20.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/includes/database.mysqli.inc 2007-07-11 18:58:03.000000000 +0800 @@ -253,7 +253,10 @@ function db_affected_rows() { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -303,7 +306,10 @@ function db_query_range($query) { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -330,16 +336,16 @@ function db_query_temporary($query) { } /** - * Returns a properly formatted Binary Large Object value. + * Returns a properly formatted Binary Large OBject value. * * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data. Return a place holder when NULL input. */ function db_encode_blob($data) { global $active_db; - return "'". mysqli_real_escape_string($active_db, $data) ."'"; + return !is_null($data) ? "'". mysqli_real_escape_string($active_db, $data) ."'" : "''"; } /** @@ -355,6 +361,31 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * + * @param $data + * Data to encode. + * @return + * Encoded data. Return a place holder when NULL input. + */ +function db_encode_clob($data) { + global $active_db; + return !is_null($data) ? "'". mysqli_real_escape_string($active_db, $data) ."'" : "''"; +} + +/** + * Returns text from a Character Large OBject value. + * + * @param $data + * Data to decode. + * @return + * Decoded data. + */ +function db_decode_clob($data) { + return $data; +} + +/** * Prepare user input for use in a database query, preventing SQL injection attacks. */ function db_escape_string($text) { diff -urpN drupal-6.x-dev-200707090006/includes/database.mysql.inc drupal-6.x-dev-clob-0.4/includes/database.mysql.inc --- drupal-6.x-dev-200707090006/includes/database.mysql.inc 2007-06-05 20:13:20.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/includes/database.mysql.inc 2007-07-12 00:55:48.000000000 +0800 @@ -255,7 +255,10 @@ function db_affected_rows() { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -305,7 +308,10 @@ function db_query_range($query) { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -337,11 +343,11 @@ function db_query_temporary($query) { * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data. Return a place holder when NULL input. */ function db_encode_blob($data) { global $active_db; - return "'". mysql_real_escape_string($data, $active_db) ."'"; + return !is_null($data) ? "'". mysql_real_escape_string($data, $active_db) ."'" : "''"; } /** @@ -357,6 +363,29 @@ function db_decode_blob($data) { } /** + * Returns a placeholder for Character Large OBject value. + * + * @return + * Placeholder. + */ +function db_encode_clob($data) { + global $active_db; + return !is_null($data) ? "'". mysql_real_escape_string($data, $active_db) ."'" : "''"; +} + +/** + * Returns text from a Character Large Object value. + * + * @param $data + * Data to decode. + * @return + * Decoded data. + */ +function db_decode_clob($data) { + return $data; +} + +/** * Prepare user input for use in a database query, preventing SQL injection attacks. */ function db_escape_string($text) { diff -urpN drupal-6.x-dev-200707090006/includes/database.pgsql.inc drupal-6.x-dev-clob-0.4/includes/database.pgsql.inc --- drupal-6.x-dev-200707090006/includes/database.pgsql.inc 2007-07-05 16:48:57.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/includes/database.pgsql.inc 2007-07-11 18:58:45.000000000 +0800 @@ -120,7 +120,10 @@ function db_connect($url) { * you may also pass a single array containing the query arguments. * * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -287,7 +290,10 @@ function db_affected_rows() { * using printf() syntax. Instead of a variable number of query arguments, * you may also pass a single array containing the query arguments. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -337,7 +343,10 @@ function db_query_range($query) { * using printf() syntax. The query arguments can be enclosed in one * array instead. * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose - * in '') and %%. + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -365,15 +374,14 @@ function db_query_temporary($query) { /** * Returns a properly formatted Binary Large OBject value. - * In case of PostgreSQL encodes data for insert into bytea field. * * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data. Return a place holder when NULL input. */ function db_encode_blob($data) { - return "'". pg_escape_bytea($data) ."'"; + return !is_null($data) ? "'". pg_escape_bytea($data) ."'" : "''"; } /** @@ -390,6 +398,32 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * + * @param $data + * Data to encode. + * @return + * Encoded data. Return a place holder when NULL input. + */ +function db_encode_clob($data) { + return !is_null($data) ? "'". pg_escape_string($data) ."'" : "''"; + +} + +/** + * Returns text from a Character Large OBject value. + * In case of PostgreSQL decodes data after select from bytea field. + * + * @param $data + * Data to decode. + * @return + * Decoded data. + */ +function db_decode_clob($data) { + return $data; +} + +/** * Prepare user input for use in a database query, preventing SQL injection attacks. * Note: This function requires PostgreSQL 7.2 or later. */ @@ -398,6 +432,103 @@ function db_escape_string($text) { } /** + * Update Character Large Object value. Wrapper function for _db_update_lob() + * + * @param $table + * Table to update. + * @param $values + * Values to update, in array format. Columns and values pairs. + * @param $where + * Update condition. + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @return + * Returns TRUE on success or FALSE on failure. + */ +function db_update_blob($table, $values, $where) { + $args = func_get_args(); + array_shift($args); + array_shift($args); + array_shift($args); + $args = is_array($args) ? $args : array($args); + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + return _db_update_lob($table, $values, $where, $args, 'BLOB'); +} + +/** + * Update Binary Large Object value. Wrapper function for _db_update_lob() + * + * @param $table + * Table to update. + * @param $values + * Values to update, in array format. Columns and values pairs. + * @param $where + * Update condition. + * @param ... + * A variable number of arguments which are substituted into the query + * WHERE condition, using printf() syntax. Instead of a variable number + * of query arguments, you may also pass a single array containing the + * query arguments. + * + * Valid %-modifiers are: %s, %d, %f, %b (binary data, do not enclose + * in ''), %c (character large object) and %%. + * + * NOTE: %b and %c should input NULL as placeholder, and further more + * manually update its value by using db_update_blob() or db_update_clob(). + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @return + * Returns TRUE on success or FALSE on failure. + */ +function db_update_clob($table, $values, $where) { + $args = func_get_args(); + array_shift($args); + array_shift($args); + array_shift($args); + $args = is_array($args) ? $args : array($args); + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + return _db_update_lob($table, $values, $where, $args, 'CLOB'); +} + +/** + * Helper function for update Large Object value. + */ +function _db_update_lob($table, $values, $where, $args, $lobtype = 'BLOB') { + _db_query_callback($args, TRUE); + $where = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $where); + + $arr = array(); + foreach ($values as $key => $value) { + switch ($lobtype) { + case 'BLOB': $arr[] = $key . " = " . db_encode_blob($value); break; + case 'CLOB': $arr[] = $key . " = '" . db_escape_string($value) . "'"; break; + } + } + + $query = 'UPDATE ' . db_prefix_tables($table) . ' SET ' . implode(', ', $arr) . ' WHERE ' . $where; + return _db_query($query); +} + +/** * Lock a table. * This function automatically starts a transaction. */ @@ -501,6 +632,9 @@ function db_type_map() { 'blob:big' => 'bytea', 'blob:normal' => 'bytea', + 'clob:big' => 'text', + 'clob:normal' => 'text', + 'datetime:normal' => 'timestamp', 'serial:tiny' => 'serial', diff -urpN drupal-6.x-dev-200707090006/modules/aggregator/aggregator.module drupal-6.x-dev-clob-0.4/modules/aggregator/aggregator.module --- drupal-6.x-dev-200707090006/modules/aggregator/aggregator.module 2007-07-05 17:07:03.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/aggregator/aggregator.module 2007-07-12 01:03:01.000000000 +0800 @@ -977,15 +977,17 @@ function aggregator_parse_feed(&$data, $ function aggregator_save_item($edit) { if ($edit['iid'] && $edit['title']) { - db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']); + db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = %c, guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], NULL, $edit['guid'], $edit['timestamp'], $edit['iid']); + db_update_clob('{aggregator_item}', array('description' => $edit['description']), 'iid = %d', $edit['iid']); } else if ($edit['iid']) { db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']); db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']); } else if ($edit['title'] && $edit['link']) { - db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']); + db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', %c, %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], NULL, $edit['timestamp'], $edit['guid']); $edit['iid'] = db_last_insert_id('aggregator_item', 'iid'); + db_update_clob('{aggregator_item}', array('description' => $edit['description']), 'iid = %d', $edit['iid']); // file the items in the categories indicated by the feed $categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']); while ($category = db_fetch_object($categories)) { @@ -1232,6 +1234,7 @@ function aggregator_page_rss() { } while ($item = db_fetch_object($result)) { + $item->description = db_decode_clob($item->description); switch (variable_get('feed_item_length', 'teaser')) { case 'teaser': $teaser = node_teaser($item->description); @@ -1407,7 +1410,7 @@ function theme_aggregator_page_item($ite $output .= "
$source $source_date
\n"; if ($item->description) { - $output .= '
'. aggregator_filter_xss($item->description) ."
\n"; + $output .= '
'. aggregator_filter_xss(db_decode_clob($item->description)) ."
\n"; } $result = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = %d ORDER BY c.title', $item->iid); diff -urpN drupal-6.x-dev-200707090006/modules/aggregator/aggregator.schema drupal-6.x-dev-clob-0.4/modules/aggregator/aggregator.schema --- drupal-6.x-dev-200707090006/modules/aggregator/aggregator.schema 2007-06-15 15:15:24.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/aggregator/aggregator.schema 2007-07-09 12:25:48.000000000 +0800 @@ -38,7 +38,7 @@ function aggregator_schema() { 'checked' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'link' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'description' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), - 'image' => array('type' => 'text', 'not null' => TRUE, 'size' => 'medium'), + 'image' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), 'etag' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'modified' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'block' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny') @@ -57,7 +57,7 @@ function aggregator_schema() { 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'link' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'author' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), - 'description' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), + 'description' => array('type' => 'clob', 'not null' => TRUE, 'size' => 'big'), 'timestamp' => array('type' => 'int', 'not null' => FALSE), 'guid' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE) ), diff -urpN drupal-6.x-dev-200707090006/modules/block/block.module drupal-6.x-dev-clob-0.4/modules/block/block.module --- drupal-6.x-dev-200707090006/modules/block/block.module 2007-07-02 05:39:07.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/block/block.module 2007-07-11 22:42:57.000000000 +0800 @@ -142,7 +142,7 @@ function block_block($op = 'list', $delt case 'view': $block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta)); - $data['content'] = check_markup($block->body, $block->format, FALSE); + $data['content'] = check_markup(db_decode_clob($block->body), $block->format, FALSE); return $data; } } @@ -538,8 +538,9 @@ function block_add_block_form_validate($ * Save the new custom block. */ function block_add_block_form_submit($form, &$form_state) { - db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']); + db_query("INSERT INTO {boxes} (body, info, format) VALUES (%c, '%s', %d)", NULL, $form_state['values']['info'], $form_state['values']['format']); $delta = db_last_insert_id('boxes', 'bid'); + db_update_clob('{boxes}', array('body' => $form_state['values']['body']), 'bid = %d', $delta); foreach (list_themes() as $key => $theme) { if ($theme->status) { @@ -620,7 +621,8 @@ function block_box_save($edit, $delta) { $edit['format'] = FILTER_FORMAT_DEFAULT; } - db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['format'], $delta); + db_query("UPDATE {boxes} SET body = %c, info = '%s', format = %d WHERE bid = %d", NULL, $edit['info'], $edit['format'], $delta); + db_update_clob('{boxes}', array('body' => $edit['body']), 'bid = %d', $delta); return TRUE; } diff -urpN drupal-6.x-dev-200707090006/modules/block/block.schema drupal-6.x-dev-clob-0.4/modules/block/block.schema --- drupal-6.x-dev-200707090006/modules/block/block.schema 2007-05-25 20:46:43.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/block/block.schema 2007-07-09 02:54:02.000000000 +0800 @@ -36,7 +36,7 @@ function block_schema() { $schema['boxes'] = array( 'fields' => array( 'bid' => array('type' => 'serial', 'not null' => TRUE), - 'body' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'), + 'body' => array('type' => 'clob', 'not null' => FALSE, 'size' => 'big'), 'info' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'format' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0) ), diff -urpN drupal-6.x-dev-200707090006/modules/comment/comment.module drupal-6.x-dev-clob-0.4/modules/comment/comment.module --- drupal-6.x-dev-200707090006/modules/comment/comment.module 2007-07-05 16:48:57.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/comment/comment.module 2007-07-12 00:56:24.000000000 +0800 @@ -484,7 +484,7 @@ function comment_nodeapi(&$node, $op, $a $text = ''; $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED); while ($comment = db_fetch_object($comments)) { - $text .= '

'. check_plain($comment->subject) .'

'. check_markup($comment->comment, $comment->format, FALSE); + $text .= '

'. check_plain($comment->subject) .'

'. check_markup(db_decode_clob($comment->comment), $comment->format, FALSE); } return $text; @@ -741,7 +741,8 @@ function comment_save($edit) { if (!form_get_errors()) { if ($edit['cid']) { // Update the comment in the database. - db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = '%s', format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']); + db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = %c, format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], NULL, $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']); + db_update_clob('{comments}', array('comment' => $edit['comment']), 'cid = %d', $edit['cid']); _comment_update_node_statistics($edit['nid']); @@ -814,8 +815,9 @@ function comment_save($edit) { } $edit += array('mail' => '', 'homepage' => ''); - db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], ip_address(), $edit['timestamp'], $status, $score, $users, $thread, $edit['name'], $edit['mail'], $edit['homepage']); + db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', %c, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], NULL, $edit['format'], ip_address(), $edit['timestamp'], $status, $score, $users, $thread, $edit['name'], $edit['mail'], $edit['homepage']); $edit['cid'] = db_last_insert_id('comments', 'cid'); + db_update_clob('{comments}', array('comment' => $edit['comment']), 'cid = %d', $edit['cid']); _comment_update_node_statistics($edit['nid']); @@ -1214,7 +1216,7 @@ function comment_admin_overview($type = while ($comment = db_fetch_object($result)) { $comments[$comment->cid] = ''; $comment->name = $comment->uid ? $comment->registered_name : $comment->name; - $form['subject'][$comment->cid] = array('#value' => l($comment->subject, 'node/'. $comment->nid, array('title' => truncate_utf8($comment->comment, 128), 'fragment' => 'comment-'. $comment->cid))); + $form['subject'][$comment->cid] = array('#value' => l($comment->subject, 'node/'. $comment->nid, array('title' => truncate_utf8(db_decode_clob($comment->comment), 128), 'fragment' => 'comment-'. $comment->cid))); $form['username'][$comment->cid] = array('#value' => theme('username', $comment)); $form['timestamp'][$comment->cid] = array('#value' => format_date($comment->timestamp, 'small')); $form['operations'][$comment->cid] = array('#value' => l(t('edit'), 'comment/edit/'. $comment->cid, array('query' => $destination))); @@ -1777,7 +1779,7 @@ function theme_comment_view($comment, $n // Switch to folded/unfolded view of the comment if ($visible) { - $comment->comment = check_markup($comment->comment, $comment->format, FALSE); + $comment->comment = check_markup(db_decode_clob($comment->comment), $comment->format, FALSE); // Comment API hook comment_invoke_comment($comment, 'view'); @@ -2205,7 +2207,7 @@ function comment_unpublish_by_keyword_ac */ function comment_unpublish_by_keyword_action($comment, $context) { foreach ($context['keywords'] as $keyword) { - if (strstr($comment->comment, $keyword) || strstr($comment->subject, $keyword)) { + if (strstr(db_decode_clob($comment->comment), $keyword) || strstr($comment->subject, $keyword)) { db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $comment->cid); watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject)); break; diff -urpN drupal-6.x-dev-200707090006/modules/comment/comment.schema drupal-6.x-dev-clob-0.4/modules/comment/comment.schema --- drupal-6.x-dev-200707090006/modules/comment/comment.schema 2007-06-15 15:15:24.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/comment/comment.schema 2007-07-09 12:31:11.000000000 +0800 @@ -9,14 +9,14 @@ function comment_schema() { 'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'subject' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''), - 'comment' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), + 'comment' => array('type' => 'clob', 'not null' => TRUE, 'size' => 'big'), 'hostname' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'score' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'medium'), 'status' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'format' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0), 'thread' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE), - 'users' => array('type' => 'text', 'not null' => FALSE, 'size' => 'medium'), + 'users' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'), 'name' => array('type' => 'varchar', 'length' => 60, 'not null' => FALSE), 'mail' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE), 'homepage' => array('type' => 'varchar', 'length' => 255, 'not null' => FALSE) diff -urpN drupal-6.x-dev-200707090006/modules/contact/contact.module drupal-6.x-dev-clob-0.4/modules/contact/contact.module --- drupal-6.x-dev-200707090006/modules/contact/contact.module 2007-07-04 03:53:01.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/contact/contact.module 2007-07-12 00:36:11.000000000 +0800 @@ -241,13 +241,16 @@ function contact_admin_edit_submit($form } $form_state['values']['recipients'] = implode(',', $recipients); if (arg(3) == 'add') { - db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', '%s', %d, %d)", $form_state['values']['category'], $form_state['values']['recipients'], $form_state['values']['reply'], $form_state['values']['weight'], $form_state['values']['selected']); + db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', %c, %d, %d)", $form_state['values']['category'], $form_state['values']['recipients'], NULL, $form_state['values']['weight'], $form_state['values']['selected']); + $cid = db_last_insert_id('contact', 'cid'); + db_update_clob('{contact}', array('reply' => $form_state['values']['reply']), 'cid = %d', $cid); drupal_set_message(t('Category %category has been added.', array('%category' => $form_state['values']['category']))); watchdog('mail', 'Contact form: category %category added.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact')); } else { - db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d WHERE cid = %d", $form_state['values']['category'], $form_state['values']['recipients'], $form_state['values']['reply'], $form_state['values']['weight'], $form_state['values']['selected'], $form_state['values']['cid']); + db_query("UPDATE {contact} SET category = '%s', recipients = '%s', reply = %c, weight = %d, selected = %d WHERE cid = %d", $form_state['values']['category'], $form_state['values']['recipients'], NULL, $form_state['values']['weight'], $form_state['values']['selected'], $form_state['values']['cid']); + db_update_clob('{contact}', array('reply' => $form_state['values']['reply']), 'cid = %d', $form_state['values']['cid']); drupal_set_message(t('Category %category has been updated.', array('%category' => $form_state['values']['category']))); watchdog('mail', 'Contact form: category %category updated.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact')); } @@ -514,7 +517,7 @@ function contact_mail_page_submit($form, } // Send an auto-reply if necessary using the current language. - if ($contact->reply) { + if (db_decode_clob($contact->reply)) { drupal_mail('contact', 'page_autoreply', $from, $language, $values, $contact->recipients); } @@ -543,7 +546,7 @@ function contact_mail($key, &$message, $ case 'page_autoreply': $contact = $params['contact']; $message['subject'] .= t('[!category] !subject', array('!category' => $contact->category, '!subject' => $params['subject']), $language->language); - $message['body'][] = $contact->reply; + $message['body'][] = db_decode_clob($contact->reply); break; case 'user_mail': case 'user_copy': diff -urpN drupal-6.x-dev-200707090006/modules/contact/contact.schema drupal-6.x-dev-clob-0.4/modules/contact/contact.schema --- drupal-6.x-dev-200707090006/modules/contact/contact.schema 2007-06-15 15:15:24.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/contact/contact.schema 2007-07-09 12:31:58.000000000 +0800 @@ -6,8 +6,8 @@ function contact_schema() { 'fields' => array( 'cid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'category' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), - 'recipients' => array('type' => 'text', 'not null' => TRUE, 'size' => 'medium'), - 'reply' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), + 'recipients' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), + 'reply' => array('type' => 'clob', 'not null' => TRUE, 'size' => 'big'), 'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'), 'selected' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny') ), diff -urpN drupal-6.x-dev-200707090006/modules/node/node.module drupal-6.x-dev-clob-0.4/modules/node/node.module --- drupal-6.x-dev-200707090006/modules/node/node.module 2007-07-05 16:48:57.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/node/node.module 2007-07-12 00:41:19.000000000 +0800 @@ -619,6 +619,8 @@ function node_load($param = array(), $re else { $node = db_fetch_object(db_query('SELECT n.nid, n.vid, n.type, n.status, n.language, n.created, n.changed, n.comment, n.promote, n.sticky, n.tnid, n.translate, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond, $arguments)); } + $node->body = db_decode_clob($node->body); + $node->teaser = db_decode_clob($node->teaser); if ($node && $node->nid) { // Call the node specific callback (if any) and piggy-back the @@ -679,13 +681,14 @@ function node_save(&$node) { // Split off revisions data to another structure $revisions_table_values = array('nid' => &$node->nid, - 'title' => $node->title, 'body' => $node->body, - 'teaser' => $node->teaser, 'timestamp' => $node->changed, + 'title' => $node->title, 'body' => NULL, + 'teaser' => NULL, 'timestamp' => $node->changed, 'uid' => $user->uid, 'format' => $node->format); $revisions_table_types = array('nid' => '%d', - 'title' => "'%s'", 'body' => "'%s'", - 'teaser' => "'%s'", 'timestamp' => '%d', + 'title' => "'%s'", 'body' => "%c", + 'teaser' => "%c", 'timestamp' => '%d', 'uid' => '%d', 'format' => '%d'); + $revisions_table_clobs = array('body' => $node->body, 'teaser' => $node->teaser); if (!empty($node->log) || $node->is_new || (isset($node->revision) && $node->revision)) { // Only store the log message if there's something to store; this prevents // existing log messages from being unintentionally overwritten by a blank @@ -713,6 +716,7 @@ function node_save(&$node) { $revisions_query = 'INSERT INTO {node_revisions} ('. implode(', ', array_keys($revisions_table_types)) .') VALUES ('. implode(', ', $revisions_table_types) .')'; db_query($revisions_query, $revisions_table_values); $node->vid = db_last_insert_id('node_revisions', 'vid'); + db_update_clob('{node_revisions}', $revisions_table_clobs, 'vid = %d', $node->vid); $op = 'insert'; } else { @@ -727,6 +731,7 @@ function node_save(&$node) { $revisions_query = 'INSERT INTO {node_revisions} ('. implode(', ', array_keys($revisions_table_types)) .') VALUES ('. implode(', ', $revisions_table_types) .')'; db_query($revisions_query, $revisions_table_values); $node->vid = db_last_insert_id('node_revisions', 'vid'); + db_update_clob('{node_revisions}', $revisions_table_clobs, 'vid = %d', $node->vid); } else { $arr = array(); @@ -736,6 +741,7 @@ function node_save(&$node) { $revisions_table_values[] = $node->vid; $revisions_query = 'UPDATE {node_revisions} SET '. implode(', ', $arr) .' WHERE vid = %d'; db_query($revisions_query, $revisions_table_values); + db_update_clob('{node_revisions}', $revisions_table_clobs, 'vid = %d', $node->vid); $update_node = FALSE; } $op = 'update'; diff -urpN drupal-6.x-dev-200707090006/modules/node/node.schema drupal-6.x-dev-clob-0.4/modules/node/node.schema --- drupal-6.x-dev-200707090006/modules/node/node.schema 2007-07-04 03:42:14.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/node/node.schema 2007-07-09 12:56:02.000000000 +0800 @@ -73,8 +73,8 @@ function node_schema() { 'vid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), - 'body' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), - 'teaser' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), + 'body' => array('type' => 'clob', 'not null' => TRUE, 'size' => 'big'), + 'teaser' => array('type' => 'clob', 'not null' => TRUE, 'size' => 'big'), 'log' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'format' => array('type' => 'int', 'not null' => TRUE, 'default' => 0) diff -urpN drupal-6.x-dev-200707090006/modules/search/search.schema drupal-6.x-dev-clob-0.4/modules/search/search.schema --- drupal-6.x-dev-200707090006/modules/search/search.schema 2007-06-15 15:15:24.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/search/search.schema 2007-07-09 12:32:27.000000000 +0800 @@ -6,7 +6,7 @@ function search_schema() { 'fields' => array( 'sid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'type' => array('type' => 'varchar', 'length' => 16, 'not null' => FALSE), - 'data' => array('type' => 'text', 'not null' => TRUE, 'size' => 'medium') + 'data' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big') ), 'indexes' => array('sid_type' => array('sid', 'type')), ); diff -urpN drupal-6.x-dev-200707090006/modules/system/system.schema drupal-6.x-dev-clob-0.4/modules/system/system.schema --- drupal-6.x-dev-200707090006/modules/system/system.schema 2007-07-04 23:49:44.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/system/system.schema 2007-07-09 12:33:08.000000000 +0800 @@ -7,7 +7,7 @@ function system_schema() { 'bid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'token' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE), 'timestamp' => array('type' => 'int', 'not null' => TRUE), - 'batch' => array('type' => 'text', 'not null' => FALSE, 'size' => 'medium') + 'batch' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big') ), 'primary key' => array('bid'), 'indexes' => array('token' => array('token')), @@ -146,7 +146,7 @@ function system_schema() { 'hostname' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), 'cache' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), - 'session' => array('type' => 'text', 'not null' => FALSE, 'size' => 'medium') + 'session' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big') ), 'primary key' => array('sid'), 'indexes' => array( @@ -187,7 +187,7 @@ function system_schema() { $schema['variable'] = array( 'fields' => array( 'name' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), - 'value' => array('type' => 'text', 'not null' => TRUE, 'size' => 'medium'), + 'value' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'), ), 'primary key' => array('name'), ); diff -urpN drupal-6.x-dev-200707090006/modules/user/user.schema drupal-6.x-dev-clob-0.4/modules/user/user.schema --- drupal-6.x-dev-200707090006/modules/user/user.schema 2007-06-15 15:15:25.000000000 +0800 +++ drupal-6.x-dev-clob-0.4/modules/user/user.schema 2007-07-09 12:33:55.000000000 +0800 @@ -27,7 +27,7 @@ function user_schema() { 'fields' => array( 'pid' => array('type' => 'serial', 'not null' => TRUE), 'rid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), - 'perm' => array('type' => 'text', 'not null' => FALSE, 'size' => 'medium'), + 'perm' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big'), 'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0) ), 'primary key' => array('pid'), @@ -62,7 +62,7 @@ function user_schema() { 'language' => array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''), 'picture' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), 'init' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'default' => ''), - 'data' => array('type' => 'text', 'not null' => FALSE, 'size' => 'medium') + 'data' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big') ), 'indexes' => array( 'access' => array('access'),