Commit 950aab5d authored by Nigel McNie's avatar Nigel McNie
Browse files

MySQL fix for externalfeed blocktype.

MySQL cannot handle unique indexes on fields that do not have a length. Even on those that do, the length is limited to 255 characters. Made sure there was a rule in the interface too.
parent b79c872d
......@@ -7,7 +7,10 @@
<TABLE NAME="blocktype_externalfeed_data">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" SEQUENCE="true" NOTNULL="true" />
<FIELD NAME="url" TYPE="text" 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="link" TYPE="text" NOTNULL="false" />
<FIELD NAME="title" TYPE="text" NOTNULL="false" />
<FIELD NAME="description" TYPE="text" NOTNULL="false" />
......
......@@ -78,7 +78,8 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
'width' => '90%',
'defaultvalue' => $url,
'rules' => array(
'required' => true
'required' => true,
'maxlength' => 255, // mysql hack, see install.xml for this plugin
),
),
);
......@@ -110,7 +111,7 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
$form->set_error('url', get_string('invalidurl', 'blocktype.externalfeed'));
}
}
if (!record_exists('blocktype_externalfeed_data', 'url', $values['url']) && !self::parse_feed($values['url'])) {
if (!$form->get_error('url') && !record_exists('blocktype_externalfeed_data', 'url', $values['url']) && !self::parse_feed($values['url'])) {
$form->set_error('url', get_string('invalidurl', 'blocktype.externalfeed'));
}
}
......
Markdown is supported
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