gadgetto/SnipWire

Installer error: Can’t save page 0: /custom-cart-fields/: It has no parent assigned

Closed this issue · 1 comments

Describe the bug
Issue poste in PW forums by @craig: https://processwire.com/talk/topic/21554-snipwire-snipcart-integration-for-processwire/page/6/?tab=comments#comment-199438

I'm testing it out at the moment, and have come up against the error that was previously reported:

Can’t save page 0: /custom-cart-fields/: It has no parent assigned

Having dug into the code, I think I found the cause. My test PW installation is in a subdirectory - not its own host - and snipWireRootUrl returns the full path include the folders:

/misc/pw-snipwire/processwire/setup/snipwire/

In the installer, as this variable is only used to set the parent page for custom-cart-fields, could ExtendedInstaller.php be updated to use the path instead of full URL?

I updated it like this, re-installed, and it worked:

// In ExtendedInstaller::__construct():

$this->snipWireRootPath = rtrim($this->wire('pages')->findOne('template=admin, name=snipwire')->path, '/') . '/';

// in _installPage():

// Page "parent" key may have "string tags"
$parent = \ProcessWire\wirePopulateStringTags(
    $item['parent'],
    array('snipWireRootPath' => $this->snipWireRootPath)
);

// In SystemResources.php

'parent' => '{snipWireRootPath}',

Fixed in 0.8.6 - thanks @craig