FIX Remove fragile logic looking for page edit link between SS versions

This commit is contained in:
Robbie Averill 2017-06-15 14:31:10 +12:00
parent 4bdeb980d9
commit 4ba3e3fa60
2 changed files with 4 additions and 17 deletions

View File

@ -201,9 +201,7 @@ class DMSDocumentAddController extends LeftAndMain
} }
/** /**
* Return a link to a page. In SS <= 3.5 this is loaded from the session, whereas in SS >= 3.6 this is set * Return a link to edit a page, deep linking into the document set given
* explicitly to a class property on CMSMain. This method checks whether the URL handler to detect this ID
* exists on CMSMain, if so include it in the URL.
* *
* @param int $pageId * @param int $pageId
* @param int $documentSetId * @param int $documentSetId
@ -211,12 +209,10 @@ class DMSDocumentAddController extends LeftAndMain
*/ */
protected function getPageEditLink($pageId, $documentSetId) protected function getPageEditLink($pageId, $documentSetId)
{ {
// Only get configuration from CMSMain, not its descendants or extensions
$urlHandlers = (array) Config::inst()->get('CMSMain', 'url_handlers', Config::UNINHERITED);
$pageIdSegment = array_key_exists('EditForm/$ID', $urlHandlers) ? $pageId . '/' : '';
return Controller::join_links( return Controller::join_links(
singleton('CMSPagesController')->Link(), CMSPageEditController::singleton()->getEditForm($pageId)->FormAction(),
sprintf('edit/EditForm/%sfield/Document Sets/item/%d', $pageIdSegment, $documentSetId) 'field/Document Sets/item',
$documentSetId
); );
} }

View File

@ -78,15 +78,6 @@ class DMSDocumentAddControllerTest extends FunctionalTest
$this->controller->setRequest($request); $this->controller->setRequest($request);
$this->assertContains('admin/pages', $this->controller->Backlink()); $this->assertContains('admin/pages', $this->controller->Backlink());
$this->assertContains('123', $this->controller->Backlink()); $this->assertContains('123', $this->controller->Backlink());
$urlHandlers = (array) Config::inst()->get('CMSMain', 'url_handlers', Config::UNINHERITED);
if (array_key_exists('EditForm/$ID', $urlHandlers)) {
// SS 3.6 and above, ensure that the page ID is in the edit URL
$this->assertContains('admin/pages/edit/EditForm/234', $this->controller->Backlink());
} else {
// SS 3.5 and below, the page ID is loaded from the session
$this->assertNotContains('234', $this->controller->Backlink());
}
} }
/** /**