diff options
author | Brett Taylor <brett@webfroot.co.nz> | 2009-08-12 16:00:46 +1200 |
---|---|---|
committer | Brenda Wallace <shiny@cpan.org> | 2009-08-12 16:17:02 +1200 |
commit | 3243612e7636b095cbcea1ceaaba00f964b1d097 (patch) | |
tree | 7f3fb175c374f3619af2f9e34be001a8faa4fd13 | |
parent | 2260cf20f5cbbda13fa470b55509c89f4f1e08e7 (diff) |
Prevents redirect URLs that have canonical URLs longer than 255 chars from being written to the database as their canonical. Redirecting URLs will instead be saved to the database as given.
The reason for this is that table 'file' column 'url' is a VARCHAR(255) in MySQL and it silently truncates URLs longer than 255 characters, breaking the url.
The proper fix for this is to improve this column, making its type TEXT, but there are no database changes for 0.8.x, so this is the next best thing for data integrity. A migration script for 0.9.x could be written to audit the database checking for redirects and updating these urls to their proper canonical url.
-rw-r--r-- | classes/File.php | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/classes/File.php b/classes/File.php index 959301eda..b2c510340 100644 --- a/classes/File.php +++ b/classes/File.php @@ -95,7 +95,8 @@ class File extends Memcached_DataObject if (empty($file_redir)) { $redir_data = File_redirection::where($given_url); $redir_url = $redir_data['url']; - if ($redir_url === $given_url) { + // TODO: max field length + if ($redir_url === $given_url || strlen($redir_url) > 255) { $x = File::saveNew($redir_data, $given_url); $file_id = $x->id; } else { |