Skip to content

Instantly share code, notes, and snippets.

@makara
Created March 7, 2011 08:58
Show Gist options
  • Save makara/858251 to your computer and use it in GitHub Desktop.
Save makara/858251 to your computer and use it in GitHub Desktop.
RW
diff --git legacy_reference.module legacy_reference.module
index 43ffc1b..99141da 100644
--- legacy_reference.module
+++ legacy_reference.module
@@ -242,7 +242,7 @@ function legacy_reference_feeds_processor_targets_alter(&$targets, $entity_type,
if ($info['type'] == 'legacy_reference') {
$targets[$name] = array(
'name' => $instance['label'],
- 'callback' => 'field_feeds_set_target_text',
+ 'callback' => 'legacy_reference_feeds_set_target',
'description' => t('The @label field of the node.', array('@label' => $instance['label'])),
);
}
@@ -255,6 +255,18 @@ function legacy_reference_feeds_processor_targets_alter(&$targets, $entity_type,
*/
/**
+ * Callback for mapping legacy_reference fields.
+ */
+function legacy_reference_feeds_set_target($source, $entity, $target, $value) {
+ // Merge multiple values into one.
+ if (is_array($value)) {
+ $value = implode("\n", $value);
+ }
+
+ return field_feeds_set_target_text($source, $entity, $target, $value);
+}
+
+/**
* Return an array of allowed reference fields.
*
* @return
diff --git boxes/ds_feedback_box.inc boxes/ds_feedback_box.inc
index aa3058f..d401b79 100644
--- boxes/ds_feedback_box.inc
+++ boxes/ds_feedback_box.inc
@@ -43,7 +43,7 @@ class ds_feedback_box extends boxes_simple {
$block = parent::render();
$block['content'] .= "<div class='buttons'>";
- $block['content'] .= l($this->options['button_title'], 'contact', array('query' => $query, 'attributes' => array('class' => array('button'))));
+ $block['content'] .= l($this->options['button_title'], 'help', array('attributes' => array('class' => array('button'))));
$block['content'] .= "</div>";
return $block;
}
diff --git ds_feedback.box.inc ds_feedback.box.inc
index 269f209..c1876e5 100644
--- ds_feedback.box.inc
+++ ds_feedback.box.inc
@@ -16,9 +16,9 @@ function ds_feedback_default_box() {
$box->options = array(
'body' => array(
'value' => 'Please report any inconsistencies, apparent data errors, or other comments on this page.',
- 'format' => '3',
+ 'format' => 'markdown',
),
- 'button_title' => 'Send feedback',
+ 'button_title' => 'Get help',
);
$export['ds_feedback'] = $box;
diff --git robots.txt robots.txt
index 7de8435..5513144 100644
--- robots.txt
+++ robots.txt
@@ -58,3 +58,11 @@ Disallow: /?q=user/password/
Disallow: /?q=user/register/
Disallow: /?q=user/login/
Disallow: /?q=user/logout/
+
+# ReliefWeb custom
+Disallow: /updates/pdf/
+Disallow: /?q=updates/pdf/
+Disallow: /node/*/pdf/
+Disallow: /?q=node/*/pdf/
+Disallow: /taxonomy/term/*/pdf/
+Disallow: /?q=taxonomy/term/*/pdf/
diff --git includes/database/mysql/schema.inc includes/database/mysql/schema.inc
index ff1d99b..5e47d54 100644
--- includes/database/mysql/schema.inc
+++ includes/database/mysql/schema.inc
@@ -132,8 +132,13 @@ class DatabaseSchema_mysql extends DatabaseSchema {
protected function createFieldSql($name, $spec) {
$sql = "`" . $name . "` " . $spec['mysql_type'];
- if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT')) && isset($spec['length'])) {
- $sql .= '(' . $spec['length'] . ')';
+ if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT'))) {
+ if (isset($spec['length'])) {
+ $sql .= '(' . $spec['length'] . ')';
+ }
+ if (!empty($spec['binary'])) {
+ $sql .= ' BINARY';
+ }
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
$sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
diff --git includes/database/schema.inc includes/database/schema.inc
index 187f9e6..d0f58ee 100644
--- includes/database/schema.inc
+++ includes/database/schema.inc
@@ -68,6 +68,9 @@
* the precision (total number of significant digits) and scale
* (decimal digits right of the decimal point). Both values are
* mandatory. Ignored for other field types.
+ * - 'binary': For type 'char', 'varchar' or 'text' fields on MySQL, forces
+ * a case-sensitive binary collation. This has no effect on other database
+ * types for which case sensitivity is already the default behavior.
* All parameters apart from 'type' are optional except that type
* 'numeric' columns must specify 'precision' and 'scale'.
* - 'primary key': An array of one or more key column specifiers (see below)
diff --git modules/simpletest/tests/upgrade/drupal-6.upload.database.php modules/simpletest/tests/upgrade/drupal-6.upload.database.php
index 94733ed..e87c089 100644
--- modules/simpletest/tests/upgrade/drupal-6.upload.database.php
+++ modules/simpletest/tests/upgrade/drupal-6.upload.database.php
@@ -115,6 +115,17 @@ db_insert('files')->fields(array(
'status' => '1',
'timestamp' => '1285708957',
))
+// Test upgrading files with the same name but different case.
+->values(array(
+ 'fid' => '11',
+ 'uid' => '1',
+ 'filename' => 'FORUM-STICKY.PNG',
+ 'filepath' => 'sites/default/files/FORUM-STICKY.PNG',
+ 'filemime' => 'image/png',
+ 'filesize' => '329',
+ 'status' => '1',
+ 'timestamp' => '1285708957',
+))
->execute();
db_insert('node')->fields(array(
@@ -236,8 +247,8 @@ db_insert('node_revisions')->fields(array(
'vid' => '53',
'uid' => '1',
'title' => 'node title 40 revision 53',
- 'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png",
- 'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png",
+ 'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\nFORUM-STICKY.PNG",
+ 'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\nFORUM-STICKY.PNG",
'log' => '',
'timestamp' => '1285709012',
'format' => '1',
@@ -395,4 +406,13 @@ db_insert('upload')->fields(array(
'list' => '1',
'weight' => '-1',
))
+// Test upgrading files with the same name but different case.
+->values(array(
+ 'fid' => '11',
+ 'nid' => '40',
+ 'vid' => '53',
+ 'description' => 'FORUM-STICKY.PNG',
+ 'list' => '1',
+ 'weight' => '0',
+))
->execute();
diff --git modules/system/system.install modules/system/system.install
index ad76e11..0f87d24 100644
--- modules/system/system.install
+++ modules/system/system.install
@@ -805,6 +805,7 @@ function system_schema() {
'length' => 255,
'not null' => TRUE,
'default' => '',
+ 'binary' => TRUE,
),
'filemime' => array(
'description' => "The file's MIME type.",
@@ -2204,6 +2205,7 @@ function system_update_7034() {
'length' => 255,
'not null' => TRUE,
'default' => '',
+ 'binary' => TRUE,
),
'filemime' => array(
'description' => "The file's MIME type.",
@@ -2918,6 +2920,23 @@ function system_update_7065() {
}
/**
+ * Apply binary collation to the file_managed.uri column.
+ */
+function system_update_7070() {
+ $spec = array(
+ 'description' => 'The URI to access the file (either local or remote).',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ 'binary' => TRUE,
+ );
+ db_drop_unique_key('file_managed', 'uri');
+ db_change_field('file_managed', 'uri', 'uri', $spec,
+ array('unique keys' => array('uri' => array('uri'))));
+}
+
+/**
* @} End of "defgroup updates-6.x-to-7.x"
* The next series of updates should start at 8000.
*/
diff --git modules/taxonomy/taxonomy.module modules/taxonomy/taxonomy.module
index f602f1d..b5d4f25 100644
--- modules/taxonomy/taxonomy.module
+++ modules/taxonomy/taxonomy.module
@@ -1613,16 +1613,7 @@ function taxonomy_field_insert($entity_type, $entity, $field, $instance, $langco
// We maintain a denormalized table of term/node relationships, containing
// only data for current, published nodes.
if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $entity_type == 'node' && $entity->status) {
- $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', ));
- foreach ($items as $item) {
- $query->values(array(
- 'nid' => $entity->nid,
- 'tid' => $item['tid'],
- 'sticky' => $entity->sticky,
- 'created' => $entity->created,
- ));
- }
- $query->execute();
+ _taxonomy_field_save_index($entity, $items);
}
}
@@ -1642,21 +1633,45 @@ function taxonomy_field_update($entity_type, $entity, $field, $instance, $langco
}
// Only save data to the table if the node is published.
if ($entity->status) {
- $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created'));
- foreach ($items as $item) {
- $query->values(array(
- 'nid' => $entity->nid,
- 'tid' => $item['tid'],
- 'sticky' => $entity->sticky,
- 'created' => $entity->created,
- ));
- }
- $query->execute();
+ _taxonomy_field_save_index($entity, $items);
}
}
}
/**
+ * Save index.
+ */
+function _taxonomy_field_save_index($entity, $items) {
+ if (empty($entity->nid) || empty($items)) {
+ return;
+ }
+ $tids = array();
+ foreach ($items as $item) {
+ $tids[$item['tid']] = $item['tid'];
+ }
+ if (empty($tids)) {
+ return;
+ }
+ // Avoid duplicates.
+ $indexed_tids = db_query("SELECT tid FROM {taxonomy_index} WHERE nid = :nid", array(':nid' => $entity->nid))->fetchCol();
+ $tids = array_diff($tids, $indexed_tids);
+ if (empty($tids)) {
+ return;
+ }
+ // Insert.
+ $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', ));
+ foreach ($tids as $tid) {
+ $query->values(array(
+ 'nid' => $entity->nid,
+ 'tid' => $tid,
+ 'sticky' => $entity->sticky,
+ 'created' => $entity->created,
+ ));
+ }
+ $query->execute();
+}
+
+/**
* Implements hook_node_delete().
*/
function taxonomy_node_delete($node) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment