Commit 649552db authored by Ben Bradshaw's avatar Ben Bradshaw
Browse files

[#3268] Max RSS Feed length is now 2048 chars

MySQL installs will fail if 2 RSS feeds with the first same 255 chars
are added but that's tough.
Postgres will be fine.
parent dba94b75
......@@ -7,10 +7,7 @@
<TABLE NAME="blocktype_externalfeed_data">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" SEQUENCE="true" NOTNULL="true" />
<!-- This field (url) should be TYPE="text", but MySQL can't handle making unique
indexes on fields that do not have an explicit length. Testing suggests it can only
handle 255 characters of uniqueness also. -->
<FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" />
<FIELD NAME="url" TYPE="text" NOTNULL="true" />
<FIELD NAME="link" TYPE="text" NOTNULL="false" />
<FIELD NAME="title" TYPE="text" NOTNULL="false" />
<FIELD NAME="description" TYPE="text" NOTNULL="false" />
......@@ -20,7 +17,6 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
<KEY NAME="urluk" TYPE="unique" FIELDS="url" />
</KEYS>
</TABLE>
</TABLES>
......
......@@ -37,6 +37,18 @@ function xmldb_blocktype_externalfeed_upgrade($oldversion=0) {
add_field($table, $field);
}
if ($oldversion < 2008042101) {
// We hit the 255 character limit for feed URLs
if (is_postgres()) {
execute_sql('ALTER TABLE blocktype_externalfeed_data ALTER COLUMN url TYPE TEXT');
}
else if (is_mysql()) {
// If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
execute_sql('ALTER TABLE blocktype_externalfeed_data DROP KEY blocextedata_url_uix'); // We have to remove then add the constraint again else the change will make MySQL cry
execute_sql('ALTER TABLE blocktype_externalfeed_data MODIFY COLUMN "url" text');
execute_sql('ALTER TABLE blocktype_externalfeed_data add unique blocextedata_url_uix (url(255))');
}
}
return true;
}
......
......@@ -40,6 +40,18 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
return array('feeds');
}
public static function postinst($prevversion) {
if ($prevversion == 0) {
// MySQL can't handle uniqueness of > 255 chars
if (is_postgres()) {
execute_sql('CREATE UNIQUE INDEX blocextedata_url_uix ON blocktype_externalfeed_data(url);');
}
else if (is_mysql()) {
execute_sql('ALTER TABLE blocktype_externalfeed_data ADD UNIQUE blocextedata_url_uix (url(255))');
}
}
}
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
if ($configdata['feedid']) {
......@@ -109,7 +121,7 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
'defaultvalue' => $url,
'rules' => array(
'required' => true,
'maxlength' => 255, // mysql hack, see install.xml for this plugin
'maxlength' => 2048, // See install.xml for this plugin - MySQL can only safely handle up to 255 chars
),
),
'full' => array(
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2008042100;
$config->release = '1.0.1';
$config->version = 2008042101;
$config->release = '1.0.2';
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment