[MAGNOLIA-5715] VersionHandlers must not install delta's for future version Created: 14/Mar/14  Updated: 01/Aug/14  Resolved: 20/Mar/14

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 4.5.17
Fix Version/s: 4.5.18, 5.2.4, 5.3

Type: Bug Priority: Neutral
Reporter: Richard Gange Assignee: Daniel Lipp
Resolution: Fixed Votes: 0
Labels: quickwin, support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File config.png     PNG File mag-update-screen.png    
Issue Links:
causality
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Release notes required:
Yes
Date of First Response:

 Description   

The module descriptor file contains the version number of the module being installed. If the VersionHandler registers deltas for versions later than the version being installed then those deltas should not be executed.

Consider the scenario:

  • I have version 1.0 installed in my webapp
  • I install version 2.0 which contains deltas for future versions

For example my version handler for 2.0 looks like this:

public class TestModuleVersionHandler extends DefaultModuleVersionHandler {

	public TestModuleVersionHandler() {
		register(DeltaBuilder.update("999.0.0", "Updates for version 999.0.0")
                .addTask(new AbstractRepositoryTask("", "") {
                    @Override
                    protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException {
                        installContext.error("error", new IllegalStateException("this should not be executed..."));
                    }
                })
        );
	}
}

My test.xml looks like this:

<module>
  <name>test</name>
  <displayName>${project.name}</displayName>
  <description>${project.description}</description>
  <class&gt;info.magnolia.TestModule</class&gt;
  <versionHandler>info.magnolia.setup.TestModuleVersionHandler</versionHandler>
  <version>1.2.0</version>

When I start up magnolia I see:

In configuration I have:



 Comments   
Comment by Richard Gange [ 14/Mar/14 ]

The reason I point to the AbstractModuleVersionHandler in the title is because I believe an easy fix would be to add an additional control statement to check version being installed against the version of the delta.

    /**
     * Registers the delta needed to update to version v from the previous one.
     * Adds a Task to update the module version in the repository.
     */
    protected void register(Delta delta) {
        final Version v = delta.getVersion();
        if (allDeltas.containsKey(v)) {
            throw new IllegalStateException("Version " + v + " was already registered in this ModuleVersionHandler.");
        }
        delta.getTasks().addAll(getDefaultUpdateTasks(v));
        delta.getConditions().addAll(getDefaultUpdateConditions(v));
        allDeltas.put(v, delta);
    }
Comment by Daniel Lipp [ 19/Mar/14 ]

We decided to fix in two flavors:

  • tolerantly (for 4.5.18 + 5.2.4)
  • log a warning and announce this will throw an Exception from 5.3 on
  • strictly (5.3)
  • throw an exception and hence abort the installation
Comment by Daniel Lipp [ 20/Mar/14 ]

as git-bridge is currently not working for this issue, here's the direct links:

5.3: https://git.magnolia-cms.com/gitweb/?p=magnolia_main.git;a=commit;h=8ea83f6b0bd73571cf539e7276d4fd091a8f7a46
5.2.x: https://git.magnolia-cms.com/gitweb/?p=magnolia_main.git;a=commit;h=231e3c4f654fb8e1e66f84e6b638fac709321a96
4.5.x: https://git.magnolia-cms.com/gitweb/?p=magnolia_main.git;a=commit;h=66985a408042ab2cb66d0a62b9001174068a2aef

Generated at Mon Feb 12 04:07:42 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.