-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tags): Corrected cases of tags having leading or trailing spaces.
Metastrings for annotation and metadata name and values are again trimmed before saving. Fixes #8123
- Loading branch information
Showing
6 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
engine/lib/upgrades/2015041400-1.11.0_dev-trim_metastrings-d9a9fdfa28a981a3.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Elgg 1.11.0-dev upgrade 2015041400 | ||
* trim_metastrings | ||
* | ||
* Trim all whitespace padding in metastrings | ||
*/ | ||
|
||
$prefix = elgg_get_config('dbprefix'); | ||
$q = "SELECT * FROM {$prefix}metastrings WHERE string REXEXP '^[ ]+|[ ]+$'"; | ||
$r = mysql_query($q); | ||
|
||
while ($ms = mysql_fetch_assoc($r)) { | ||
// find if trimmed version collides with existing MS | ||
$string = sanitize_string(trim($ms['string'])); | ||
$existing = get_data_row("SELECT * FROM {$prefix}metastrings WHERE string = BINARY '$string' LIMIT 1"); | ||
|
||
if ($existing) { | ||
// delete the padded string and update MD / annotations to use the existing trimmed one | ||
$q = "DELETE FROM {$prefix}metastrings WHERE id = {$ms['id']} LIMIT 1"; | ||
if (delete_data($q)) { | ||
update_data("UPDATE {$prefix}metadata SET name_id = '{$existing->id}' where name_id = '{$ms['id']}'"); | ||
update_data("UPDATE {$prefix}metadata SET value_id = '{$existing->id}' where value_id = '{$ms['id']}'"); | ||
|
||
update_data("UPDATE {$prefix}annotations SET name_id = '{$existing->id}' where name_id = '{$ms['id']}'"); | ||
update_data("UPDATE {$prefix}annotations SET value_id = '{$existing->id}' where value_id = '{$ms['id']}'"); | ||
} | ||
} else { | ||
update_data("UPDATE {$prefix}metastrings SET string = '$string' where id = '{$ms['id']}'"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters