/** * Test for URL-alias issue which could occur when a parent entry was split * across multiple IDs, and children with various language masks did not * receive the correct parent id. Such a case with a split parent id, made * it impossible to handle this situation correctly. * * The fix constitutes of always creating the current entries for an action * in the same id. * * @link http://issues.ez.no/12720 */ public static function testSplitParentSyndrome() { $db = eZDB::instance(); // Ordered array containing the current name for an entry at level, // where level is the same as the index. $nameStructure = array(); $nameStructure[] = array(__FUNCTION__); // STEP 1: Create Root folder $rootFolder = new ezpObject("folder", 2); $rootFolder->name = $nameStructure[0][0]; $rootFolder->publish(); $rootId = $rootFolder->mainNode->node_id; // STEP 2: Create Child article $nameStructure[] = array("ChildNode"); $child = new ezpObject("article", $rootFolder->mainNode->node_id); $child->title = $nameStructure[1][0]; $child->publish(); $childId = $child->mainNode->node_id; $query = self::buildSql(array(2, $rootId, $childId)); $rows = $db->arrayQuery($query); $result = self::verifyUrlEntryParentStructure($nameStructure, $rows); self::assertTrue($result, "Fail after step 2"); // STEP 4: Renaming root folder // Updating the name structure on renames $nameStructure[0] = array("TestContainerA"); $rootFolder->name = $nameStructure[0][0]; $rootFolder->publish(); // STEP 5: Renaming root folder $nameStructure[0] = array("TestContainerB"); $rootFolder->name = $nameStructure[0][0]; $rootFolder->publish(); $rows = $db->arrayQuery($query); $result = self::verifyUrlEntryParentStructure($nameStructure, $rows); self::assertTrue($result, "Fail after step 5"); // STEP 6: Rename root folder back to name in history. $nameStructure[0] = array("TestContainer"); $rootFolder->name = $nameStructure[0][0]; $rootFolder->publish(); $rows = $db->arrayQuery($query); $result = self::verifyUrlEntryParentStructure($nameStructure, $rows); self::assertTrue($result, "Fail after step 6"); // STEP 7: Translate root folder into norwegian. $nameStructure[0][] = "TestBinge"; $trData = array("name" => $nameStructure[0][1]); $rootFolder->addTranslation("nor-NO", $trData); $rows = $db->arrayQuery($query); $result = self::verifyUrlEntryParentStructure($nameStructure, $rows); self::assertTrue($result, "Fail after step 7"); // STEP 8: Translate childe article into norwegian $nameStructure[1][] = "BarneNode"; $trData = array("title" => $nameStructure[1][1]); $child->addTranslation("nor-NO", $trData); $rows = $db->arrayQuery($query); $result = self::verifyUrlEntryParentStructure($nameStructure, $rows); self::assertTrue($result, "Fail after step 8"); // STEP 9: We rename the Norwegian translation of the child element to the // same name as the English translation unset($nameStructure[1][1]); $child->refresh(); $newVersion = $child->createNewVersion(false, true, 'nor-NO'); $norDataMap = $child->fetchDataMap($newVersion->attribute('version'), "nor-NO"); $norDataMap['title']->setAttribute('data_text', $nameStructure[1][0]); $norDataMap['title']->store(); ezpObject::publishContentObject($child->object, $newVersion); $rows = $db->arrayQuery($query); $result = self::verifyUrlEntryParentStructure($nameStructure, $rows); self::assertTrue($result, "Fail after step 9"); // STEP 10: We remove Norwegian translation. $child->refresh(); $child->removeTranslation("nor-NO"); $rows = $db->arrayQuery($query); $result = self::verifyUrlEntryParentStructure($nameStructure, $rows); self::assertTrue($result, "Fail after step 10"); }