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
    With Revo solid enough to install on remote sites, I thought I’d ask about the ins and outs of moving the core directory.

    What are the steps to install the core in a different place on a new install?

    What are the steps to move the core on an existing install?

    If using SVN, how does having a moved core affect updating (especially, how do you keep SVN from replacing the "missing" core directory)?

    Are there any extra steps necessary for future builds and setups?

      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
    • Quote from: BobRay at Mar 17, 2009, 07:27 PM

      What are the steps to install the core in a different place on a new install?
      Just move the contents of core/ where you want it, then simply edit the MODX_CORE_PATH define in setup/includes/core.config.php and run setup.

      Quote from: BobRay at Mar 17, 2009, 07:27 PM

      What are the steps to move the core on an existing install?
      Just move the contents of core/ where you want it, then edit the MODX_CORE_PATH define in setup/includes/core.config.php and run setup in upgrade mode, OR, edit it in each of the following files manually:

      MODX_SETUP_PATH/core.config.php
      MODX_BASE_PATH/core.config.php
      MODX_MANAGER_PATH/core.config.php
      MODX_CONNECTORS_PATH/core.config.php

      Quote from: BobRay at Mar 17, 2009, 07:27 PM

      If using SVN, how does having a moved core affect updating (especially, how do you keep SVN from replacing the "missing" core directory)?

      Are there any extra steps necessary for future builds and setups?
      This is a little different, and generally, I only deploy the core itself via SVN when deploying on a remote site from SVN, IOW, in the directory where I want my core to be located I simply execute
      svn co http://svn.modxcms.com/svn/tattoo/tattoo/branches/revolution/core .

      Once it’s there, I generate a transport package in my local development copy (of the same revision of course) and upload it to the MODX_CORE_PATH/packages/ directory.

      From there you simply let setup install the files from the transport package to the rest of the locations configurable during the setup process, or I suppose you could also checkout index.php, manager/, and connectors/ separately to the specific locations you wanted and check the files already in-place option.

      In general though, I wouldn’t plan on using an SVN development copy on your local workstation with locations other than the default for everything, or you’ll just complicate your life unnecessarily.
        • 3749
        • 24,544 Posts
        Thanks!

        I moved the /core dir. above htdocs on a localhost site and everything works except captcha. Darned if I can figure out why. I looked at all the Captcha code and it looks fine.

        I didn’t move /connectors or /manager.

        Bob
          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
        • Any errors in cache/logs/error.log? (or cache/MODX_CONFIG_KEY/logs/error.log if your MODX_CONFIG_KEY != ’config’)
          • After a quick look at Captcha, that is not the way Captcha should ideally work; this really needs to go through the MODx gateway, i.e. captcha.php should be a Resource + Snippet on the front-end and a controller or plugin on the back-end. But regardless of this fact, in order to make it work, you would need to first include a config.core.php file or define all of the same values there. You could generate one via a resolver in your transport package, but I’d really prefer it go through the existing gateways to become a reference component.

            Ultimately the problem is going to be locating a config.core.php file to include if they are located in various places (depending on a how you configure your paths), and I’m hoping that’s motivation to deter creating components that contain their own gateways with directly accessible php files.
              • 3749
              • 24,544 Posts
              Quote from: OpenGeek at Mar 18, 2009, 12:41 AM

              Any errors in cache/logs/error.log? (or cache/MODX_CONFIG_KEY/logs/error.log if your MODX_CONFIG_KEY != ’config’)
              There are no logs (or log dir.) under the cache dir.

              It turned out to be this line in captcha.php:

              if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR);


              Putting the following line above it fixed things:

              include dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR.'config.core.php';


              Actually, I think the original line can be removed since captcha.php is always accessed as an img URL and MODX_CORE_PATH would never be defined at that point.
                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
              • Quote from: BobRay at Mar 18, 2009, 12:56 AM

                if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR);

                Absolutely not; you’ll need to either create and maintain your own config.core.php file that defines this, or go through the gateway as I suggest. IOW, no php files should be directly accessed from the browser other than index.php or manager/index.php.
                Quote from: BobRay at Mar 18, 2009, 12:56 AM

                Actually, I think the original line can be removed since captcha.php is always accessed as an img URL and MODX_CORE_PATH would never be defined at that point.
                Again, this should be being served by an existing gateway, not captcha.php.
                  • 3749
                  • 24,544 Posts
                  Quote from: OpenGeek at Mar 18, 2009, 12:51 AM

                  Ultimately the problem is going to be locating a config.core.php file to include if they are located in various places (depending on a how you configure your paths), and I’m hoping that’s motivation to deter creating components that contain their own gateways with directly accessible php files.

                  I didn’t exactly create a component that contains its own gateway. I adapted an existing component that already had one (and I did it with a ton of consultation as you’ll recall). I put many, many hours into developing the current captcha plugin and it won’t be easy to find the motivation to start over.

                  When you say "absolutely not," I can’t tell what you’re referring to and whether you’re agreeing with me or telling me my approach is a huge mistake.

                  All captcha.php does is produce the image and write a corresponding $_SESSION variable (and it’s been around in MODx for a long, long time) so I don’t think it’s a huge security vulnerability, although I understand the general policy of not having the browser access .php files directly. In use, it’s always accessed as the src in an <img> tag. Accessing it directly will give the user a look at a captcha image.

                  Isn’t it fairly safe to assume that there will be a config.core.php in the site root?
                    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
                  • Quote from: BobRay at Mar 18, 2009, 03:15 PM

                    Quote from: OpenGeek at Mar 18, 2009, 12:51 AM

                    Ultimately the problem is going to be locating a config.core.php file to include if they are located in various places (depending on a how you configure your paths), and I’m hoping that’s motivation to deter creating components that contain their own gateways with directly accessible php files.

                    I didn’t exactly create a component that contains its own gateway. I adapted an existing component that already had one (and I did it with a ton of consultation as you’ll recall). I put many, many hours into developing the current captcha plugin and it won’t be easy to find the motivation to start over.

                    When you say "absolutely not," I can’t tell what you’re referring to and whether you’re agreeing with me or telling me my approach is a huge mistake.

                    All captcha.php does is produce the image and write a corresponding $_SESSION variable (and it’s been around in MODx for a long, long time) so I don’t think it’s a huge security vulnerability, although I understand the general policy of not having the browser access .php files directly. In use, it’s always accessed as the src in an <img> tag. Accessing it directly will give the user a look at a captcha image.

                    Isn’t it fairly safe to assume that there will be a config.core.php in the site root?
                    Yes, but what’s not safe is to claim to know where it is relative to the assets_path setting. So yes, you could include MODX_BASE_PATH . config.core.php, but you don’t know what MODX_BASE_PATH is until it’s included.
                      • 3749
                      • 24,544 Posts
                      Fair enough, but it would work in any setting where the assets path hadn’t been changed from the default. I don’t see any other alternative but to redo the whole package. The problem is that if captcha.php is is a resource, any other component that wants to use it would have to know the id (or at least the name) of the resource. I think it would also have to be published, which might create the same security problems it poses now.
                        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