We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I’m working on a new version of SPForm that needs to do some things on upgrade but the "install" section of the resolver script runs no matter what.
    If I install version 3.1.3, then install version 3.1.4, the install section runs.
    If I uninstall, the uninstall section runs.

    PM doesn’t seem to be aware that it’s an upgrade. Do I need to set something myself to indicate an upgrade?

    <?php
    switch($options[xPDOTransport::PACKAGE_ACTION]) {
        case xPDOTransport::ACTION_INSTALL:
            $object->xpdo->log(xPDO::LOG_LEVEL_INFO,'Installing');
            $success =  true;
            break;
        case xPDOTransport::ACTION_UPGRADE:
             $object->xpdo->log(xPDO::LOG_LEVEL_INFO,'Upgrading');
            $success = true;
            break;
        case xPDOTransport::ACTION_UNINSTALL:
            $object->xpdo->log(xPDO::LOG_LEVEL_INFO,'Un-Installing');
           $success = true;
            break;
    }
    $object->xpdo->log(xPDO::LOG_LEVEL_INFO,'Script resolver actions completed');
    return $success;
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 28215
      • 4,149 Posts
      This might be a bug. Can you file it?
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 3749
        • 24,544 Posts
        Done.
        http://bugs.modx.com/issues/3464

        BTW, I noticed another weird anomaly. I reported this a while back, but I don’t think anyone was able to reproduce it.

        SPForm’s uninstall has never removed the two resources it creates (and doesn’t mention them in the console during the uninstall). I finally got around to removing them myself in the uninstall code of the script resolver. Now the console output indicates that it’s skipping them because they don’t exist (hah -- where were you when I needed you).

        I wonder if it’s because the resources are created by the build script, but they’re also retrieved, altered, and saved in the script resolver.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 28215
          • 4,149 Posts
          What’s your UNIQUE_KEY on the resource’s vehicle attributes?
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 3749
            • 24,544 Posts
            Quote from: splittingred at Jan 13, 2011, 10:03 PM

            What’s your UNIQUE_KEY on the resource’s vehicle attributes?

            xPDOTransport::UNIQUE_KEY => 'pagetitle',
            xPDOTransport::UPDATE_OBJECT => false,
            xPDOTransport::PRESERVE_KEYS => false,


            Could UPDATE_OBJECT => false be the problem. I didn’t want to overwrite people’s existing Contact pages on an update.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28215
              • 4,149 Posts
              Nope, but if they change the pagetitle, the remove will fail, since it’s looking for the Resource via that.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 3749
                • 24,544 Posts
                Quote from: splittingred at Jan 14, 2011, 08:25 AM

                Nope, but if they change the pagetitle, the remove will fail, since it’s looking for the Resource via that.

                The pagetitle has never changed in any of my tests, so that’s definitely not the issue with the resources not being removed.

                Would it make sense to use ID as the UNIQUE_KEY in this case?

                It’s embarrassing, but after all this time, I still don’t fully understand the attributes. I understand what they are, sort of, but don’t really know how they operate.

                For example, what happens if you set UNIQUE_KEY to pagetitle and the package creates a ’Contact’ page when there already is one with that pagetitle -- and do the other two attributes influence the behavior in that situation?
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting