Dear XWiki developers,

the last couple of days I tried setting up two redundant XWiki servers
using MySQL master/slave replication. Unfortunately MySQL replication
produced errors, because the slave wiki also wrote on the DB.
Thus, I revoked update privileges from the xwiki DB user on the slave.
Now replication worked, but the slave XWiki failed to start and instead
always threw an exception in  XWiki.getUserClass().

Unlike mentioned in previous findings by others
(http://lists.xwiki.org/pipermail/devs/2011-January/045992.html),
currently XWiki seems to be unable to operate on a read-only DB.

I think I tracked the issue to the following code in XWiki.getUserClass()
(lines 3000ff, shown below). As you can see, the if block only operates on
a local string builder, but does not change the page. Nevertheless,
needsUpdate is set to true, thus forcing XWiki to save the document,
which doesn't work on a read-only DB.
This happens every time XWiki starts.

// Email field custom display (email obfuscation).
PropertyClass emailProperty = (PropertyClass) bclass.get("email");
if (!emailProperty.isCustomDisplayed(context)) {
    StringBuilder builder = new StringBuilder();
    builder.append("{{velocity}}\n");
builder.append("#if ($xcontext.action == 'edit' || $xcontext.action == 'inline')\n");
    // Line broken in 2 because it was too long.
    builder.append("  {{html}}<input id='$prefix$name' type='text'");
    builder.append(" name='$prefix$name' value='$value' />{{/html}}\n");
    builder.append("#else\n");
builder.append(" ## Allow $obfuscateEmail to be set in some other place.\n");
    builder.append("  #if(\"$obfuscateEmail\" == 'false')\n");
    builder.append("    $value\n");
    builder.append("  #else\n");
    builder.append("    $value.replaceAll('@.*', '@ xxxxxx')\n");
    builder.append("  #end\n");
    builder.append("#end\n");
    builder.append("{{/velocity}}");
    needsUpdate = true;
}
...
if (needsUpdate) {
    saveDocument(doc, context);
}


Without the 'needsUpdate = true;' the slave xwiki now starts fine and seems to work properly. Note, that i tried setting 'xwiki.readonly=yes' in xwiki.cfg as also recommended in the previous thread, but that had no effect on the above issue.

I would prefer being able to use the official xwiki distribution instead of my
own fixed build. Is there any chance that a fix to the above issue (given my
evaluation is indeed correct) will make it into some upcoming release/milestone? Unfortunately, I do not understand the intention of the email obfuscation code
above, otherwise I maybe would have been able to supply a patch myself.

Kind regards and thanks in advance,
Alex

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to