Issue Details (XML | Word | Printable)

Key: XWIKI-603
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Vincent Massol
Reporter: Yoav Shapira
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XWiki Core

Log message that says schema update deactivated should be DEBUG or INFO, not ERROR

Created: 22/Dec/06 16:13   Updated: 26/Dec/06 13:04
Component/s: Storage
Affects Version/s: 0.9.840
Fix Version/s: 1.0 B2

Environment: All

keywords: logging log error
Date of First Response: 26/Dec/06 10:07
Resolution Date: 26/Dec/06 10:07


 Description  « Hide
In XWikiHibernateBaseStore, updateSchema method, there are two logging messages at ERROR level. Neither is an error or even a warning, so their logging level should be changed. I suggest the first one to be DEBUG, since the server isn't even doing anything when schema update is disabled and the admin would have had to turn this schema update feature off in the config file. The second one is probably INFO. There's also no particular reason for having this in a try / catch clause, especially since the exception is silently ignored. In code terms, replace:
// No updating of schema if we have a config parameter saying so
        try {
            if ((!force)&&("0".equals(context.getWiki().Param("xwiki.store.hibernate.updateschema")))) {
                if (log.isErrorEnabled())
                    log.error("Schema update deactivated for wiki " + context.getDatabase());
                return;
            }

            if (log.isErrorEnabled())
                log.error("Schema update for wiki " + context.getDatabase());

        } catch (Exception e) {}

With:

if ((!force)&&("0".equals(context.getWiki().Param("xwiki.store.hibernate.updateschema")))) {
  log.info("Not updating schema: see the xwiki.store.hibernate.updateschema configuration parameter.");
  return;
} else [
  log.info("Updating schema since xwiki.store.hibernate.updateschema is set.");
}


 All   Comments   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Vincent Massol added a comment - 26/Dec/06 10:07
Yoav, the code was already fixed when I reviewed this patch. however I made additional changes. Here's the new code:
public synchronized void updateSchema(XWikiContext context, boolean force) throws HibernateException {

        // We don't update the schema if the XWiki hibernate config parameter says not to update
        if ((!force) && (context.getWiki() != null) && ("0".equals(context.getWiki().Param("xwiki.store.hibernate.updateschema")))) {
            if (log.isDebugEnabled())
                log.debug("Schema update deactivated for wiki " + context.getDatabase());
            return;
        }
        
        if (log.isInfoEnabled()) {
            log.info("Updating schema update for wiki " + context.getDatabase() + " ...");
        }

        try {
[...]
        } finally {
            if (log.isInfoEnabled()) {
                log.info("Schema update for wiki " + context.getDatabase() + " done");
            }
        }
    }

Yoav Shapira added a comment - 26/Dec/06 13:04
Sweet, thank you.