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.
This commit is contained in:
parent
2260cf20f5
commit
3243612e76
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user