We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39854
    • 9 Posts
    I am attempting to use the xPDO Wordpress to MODx Migration Code on GitHub: https://github.com/devtrench/WordPress-to-MODx to copy resources to a localhost (xampp) install of Revolution 2.2. I have configured the files per the instructions but am running into a couple of error messages that I don't know how to resolve.

    Upon executing the php file I am receiving the following error messages:

    Notice: Undefined property: modX::$db in xampp\htdocs\cgroup\core\model\wordpress\wp-migrate.php on line 134

    Notice: Trying to get property of non-object in xampp\htdocs\cgroup\core\model\wordpress\wp-migrate.php on line 134

    Notice: Undefined property: modX::$db in xampp\htdocs\cgroup\core\model\wordpress\wp-migrate.php on line 157

    Fatal error: Call to a member function query() on a non-object in xampp\htdocs\cgroup\core\model\wordpress\wp-migrate.php on line 157

    I've posted the lines in question 134 and 157 to http://pastie.org/5661856

    Any advice on how to proceed? The script successfully created a new container resource I named 'Articles' in the configuration file, but nothing more. If this is tied to the comments then I would be willing to lose those if it meant I could have the resources in full.

    Thanks!
    David
      • 22840
      • 1,572 Posts
      May sound like a stupid question but Articles and Quip are installed on your modx install aren't they ?
        • 39854
        • 9 Posts
        I thought that might be the issue, too. I installed Quip, but not Articles. I tried the Articles extra but didn't like the way it worked - I want to see the individual resources in the tree.
          • 39854
          • 9 Posts
          I think this may have something to do with an updated xpdo of which I have no understanding. I may try this procedure using the same versions as this script was last tested with and then upgrade modx after migration.
            • 3749
            • 24,544 Posts
            I don't think $modx->db works any more. I think the fix would be to hard-code your table prefix in line 133, then set $empty_tables to false or delete lines 153-165 (empty the tables first in PhpMyAdmin if you want them wiped):



            If that doesn't work, and it doesn't work with an older version of MODX, check the paths in core/model/wordpress/wp-migrate.php around line 129-120. Those paths will depend on where you install the script.

            There should probably be file_exists() checks for both those files.
              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
              • 3749
              • 24,544 Posts
              This is weird. I tried to post an example for line 133 and got blocked by Firehost's firewall.
                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
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                I think you need Articles installed -- you could use its WP import functionality that's built-in. Articles doesn't show all posts in the resource tree, it just shows the parent container.

                You could just do this in MySQL... the WP tables are simpler, but it's more or less the same pattern as MODx uses.
                  • 3749
                  • 24,544 Posts
                  Everett, you might be right, but I don't see anything in the code that refers to Articles or the Article class key, though it couldn't hurt to have Articles installed.

                  That error definitely points to the $modx->db code.
                    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
                    • 39854
                    • 9 Posts
                    Thanks, all. Following your advice nearly gets me out of the woods. Running into one last error at end of script:

                    Notice: Undefined variable: parent_resource in xampp\htdocs\cgroup\core\model\wordpress\wp-migrate.php on line 453

                    Lines 446-456:
                    // if the parent is an integer, get the resource
                    if (is_int($parent))
                    {
                    $parent_resource = $modx->getObject('modResource',$parent);
                    }

                    // if the parent already exists return true
                    if(is_object($parent_resource)) // <-- Error Here
                    {
                    return $parent;
                    }
                      • 3749
                      • 24,544 Posts
                      Put this line above line 446:

                      $parent_resource = null;
                        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