Index: drupal/includes/cache.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/cache.inc,v retrieving revision 1.14 diff -u -p -r1.14 cache.inc --- drupal/includes/cache.inc 26 Aug 2007 09:33:49 -0000 1.14 +++ drupal/includes/cache.inc 31 Aug 2007 19:34:12 -0000 @@ -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("cid = '%s'", $cid, db_prefix_tables('{' . $table . '}'), 'data', $data); } /** Index: drupal/includes/database.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.inc,v retrieving revision 1.78 diff -u -p -r1.78 database.inc --- drupal/includes/database.inc 30 Aug 2007 19:54:21 -0000 1.78 +++ drupal/includes/database.inc 31 Aug 2007 19:34:13 -0000 @@ -182,15 +182,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. + return db_encode_blob(array_shift($args)); + case '%c': // Character Large OBject. + 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. Index: drupal/includes/database.mysql-common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.mysql-common.inc,v retrieving revision 1.9 diff -u -p -r1.9 database.mysql-common.inc --- drupal/includes/database.mysql-common.inc 26 Aug 2007 08:27:09 -0000 1.9 +++ drupal/includes/database.mysql-common.inc 31 Aug 2007 19:34:14 -0000 @@ -26,7 +26,11 @@ * 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -216,6 +220,9 @@ function db_type_map() { 'blob:big' => 'LONGBLOB', 'blob:normal' => 'BLOB', + 'clob:big' => 'LONGTEXT', + 'clob:normal' => 'TEXT', + 'datetime:normal' => 'DATETIME', ); return $map; @@ -481,5 +488,91 @@ function db_last_insert_id($table, $fiel } /** + * Update the Binary Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @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 and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_blob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_blob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** + * Update the Character Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @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 and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_clob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_clob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** * @} End of "ingroup schemaapi". - */ \ No newline at end of file + */ Index: drupal/includes/database.mysql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.mysql.inc,v retrieving revision 1.79 diff -u -p -r1.79 database.mysql.inc --- drupal/includes/database.mysql.inc 29 Aug 2007 18:38:55 -0000 1.79 +++ drupal/includes/database.mysql.inc 31 Aug 2007 19:34:15 -0000 @@ -244,7 +244,11 @@ 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -293,7 +297,11 @@ 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -325,11 +333,11 @@ function db_query_temporary($query) { * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data, or empty LOB value placeholder for NULL $data. */ 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) ."'" : "''"; } /** @@ -345,6 +353,31 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * + * @param $data + * Data to encode. + * @return + * Encoded data, or empty LOB value placeholder for NULL $data. + */ +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) { Index: drupal/includes/database.mysqli.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.mysqli.inc,v retrieving revision 1.43 diff -u -p -r1.43 database.mysqli.inc --- drupal/includes/database.mysqli.inc 29 Aug 2007 18:38:55 -0000 1.43 +++ drupal/includes/database.mysqli.inc 31 Aug 2007 19:34:16 -0000 @@ -243,7 +243,11 @@ 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -292,7 +296,11 @@ 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -324,11 +332,11 @@ function db_query_temporary($query) { * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data, or empty LOB value placeholder for NULL $data. */ 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) ."'" : "''"; } /** @@ -344,6 +352,31 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * + * @param $data + * Data to encode. + * @return + * Encoded data, or empty LOB value placeholder for NULL $data. + */ +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) { Index: drupal/includes/database.pgsql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.pgsql.inc,v retrieving revision 1.57 diff -u -p -r1.57 database.pgsql.inc --- drupal/includes/database.pgsql.inc 29 Aug 2007 18:38:55 -0000 1.57 +++ drupal/includes/database.pgsql.inc 31 Aug 2007 19:34:17 -0000 @@ -120,7 +120,11 @@ 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -272,7 +276,11 @@ 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -321,7 +329,11 @@ 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, do not enclose in '') and %%. + * + * NOTE: use NULL as arguments substitution for %b and %c. This will be + * replaced as corresponding empty LOB value placeholder, based on the + * database specific representation. * * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, * and TRUE values to decimal 1. @@ -349,15 +361,15 @@ function db_query_temporary($query) { /** * Returns a properly formatted Binary Large OBject value. - * In case of PostgreSQL encodes data for insert into bytea field. + * In case of PostgreSQL encodes data for insert or update into bytea field. * * @param $data * Data to encode. * @return - * Encoded data. + * Encoded data, or empty LOB value placeholder for NULL $data. */ function db_encode_blob($data) { - return "'". pg_escape_bytea($data) ."'"; + return !is_null($data) ? "'". pg_escape_bytea($data) ."'" : "''"; } /** @@ -374,6 +386,33 @@ function db_decode_blob($data) { } /** + * Returns a properly formatted Character Large OBject value. + * In case of PostgreSQL encodes data for insert or update into text field. + * + * @param $data + * Data to encode. + * @return + * Encoded data, or empty LOB value placeholder for NULL $data. + */ +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. */ @@ -382,6 +421,92 @@ function db_escape_string($text) { } /** + * Update the Binary Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @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 and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_blob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_blob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** + * Update the Character Large Object value, based on the database specific + * implementation. + * + * @param $query + * A string containing an update condition query (where clause). + * @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 and %%. + * + * NOTE: using this syntax will cast NULL and FALSE values to decimal 0, + * and TRUE values to decimal 1. + * + * @param $table + * Table to update. + * @param $column + * Column to update. + * @param $value + * Values to update. + * @return + * A database query result resource, or FALSE if the query was not + * executed correctly. + */ +function db_update_clob($query) { + $args = func_get_args(); + $value = array_pop($args); + $column = array_pop($args); + $table = array_pop($args); + array_shift($args); + + if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax + $args = $args[0]; + } + _db_query_callback($args, TRUE); + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); + $query = 'UPDATE ' . $table . ' SET ' . $column . ' = ' . db_encode_clob($value) . ' WHERE ' . $query; + return _db_query($query); +} + +/** * Lock a table. * This function automatically starts a transaction. */ @@ -485,6 +610,9 @@ function db_type_map() { 'blob:big' => 'bytea', 'blob:normal' => 'bytea', + 'clob:big' => 'text', + 'clob:normal' => 'text', + 'datetime:normal' => 'timestamp', 'serial:tiny' => 'serial', Index: drupal/modules/aggregator/aggregator.module =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v retrieving revision 1.353 diff -u -p -r1.353 aggregator.module --- drupal/modules/aggregator/aggregator.module 30 Aug 2007 20:20:38 -0000 1.353 +++ drupal/modules/aggregator/aggregator.module 31 Aug 2007 19:34:22 -0000 @@ -981,15 +981,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('iid = %d', $edit['iid'], db_prefix_tables('{aggregator_item}'), 'description', $edit['description']); } 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('iid = %d', $edit['iid'], db_prefix_tables('{aggregator_item}'), 'description', $edit['description']); // 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)) { @@ -1236,6 +1238,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); @@ -1411,7 +1414,7 @@ function theme_aggregator_page_item($ite $output .= "
\n"; if ($item->description) { - $output .= '