upgradeSteps get run past the metadata version

I have a Plone site with a certain addon, call it x.y, with GenericSetup profile version 1. In that addon's code, I have metadata.xml with:

<metadata>
    <version>2</version>
    …
</metadata>

And I have upgrades.zcml with

<configure…>
    <gs:upgradeStep source='1' destination='2' handler='x.y.a'/>
    <gs:upgradeStep source='2' destination='3' handler='x.y.b'/>
    <gs:upgradeStep source='2' destination='3' handler='x.y.c'/>
    <gs:upgradeStep source='2' destination='3' handler='x.y.d'/>
</configure>

If I upgrade addon x.y through the web, I expect handler x.y.a to be called, because the metadata.xml profile version is 2.

What happens though is all of the handlers x.y.a, x.y.b, x.y.c, and x.y.d get called.

Is this the correct behavior?

1 Like

Everyone should be called. What's wrong with the addon is that metadata.xml should be in version 3 and not in version 2.

1 Like

Then why is there even a destination= in upgradeStep if it's not honored?

(Let me motivate the use case: management wanted a bunch of new features in the next release. Then they decided to cut back. I thought just reducing the <version> would do it, but was surprised all my upgrade steps got run anyway. For now I've commented them out.)

Destination serves as starting point for upgrades in future versions of addon. When you run an upgrade step, your destination will be the current version of the profile in GenericSetup. In your example, the profile version after execution will be 3. In a future version of the addon it would have something like:

<gs:upgradeStep source='3' destination='4' handler='x.y.d'/>

This would serve to tell GenericSetup that there are upgrade to be run.

In your case, I think the best thing to do is really comment.