[BUGFIX] Content elements disappear on publishing a page
authorOliver Hader <oliver@typo3.org>
Tue, 3 Jul 2012 12:23:45 +0000 (14:23 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 4 Jul 2012 08:17:17 +0000 (10:17 +0200)
The different ways of versioning (element, page, branch) have
been defined to element versioning some TYPO3 version ago. With
TYPO3 4.7, those settings, especially the handling of the field
t3ver_swapmode has been removed from t3lib_TCEmain.

This leads to a chain of problems since the value of that field
will now be "0" per default which means "page versioning".

Change-Id: Ifa4dd51a02705b29c8b91ba428b18aa976a9e1de
Fixes: #38063
Releases: 6.0, 4.7
Reviewed-on: http://review.typo3.org/12533
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/version/class.tx_version_gui.php
typo3/sysext/version/class.tx_version_tcemain.php
typo3/sysext/version/cm1/index.php
typo3/sysext/version/ws/class.wslib.php

index 1f2acd3..ce2cc7d 100644 (file)
@@ -128,80 +128,39 @@ class tx_version_gui {
                                break;
                        }
 
-                       if (t3lib_BEfunc::isPidInVersionizedBranch($id) == 'branchpoint') {
-                               return '
-
-                                       <!--
-                                               Version selector:
-                                       -->
-                                       <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                               <tr>
-                                                       <td>' . $selectorLabel . '</td>
-                                                       <td>Workspace: "' . htmlspecialchars($wsTitle) . '"</td>
-                                                       <td><em>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.inBranch', TRUE) . '</em></td>
-                                               </tr>
-                                       </table>
-                               ';
-                       } else {
-
-                                       // Get Current page record:
-                               $curPage = t3lib_BEfunc::getRecord('pages', $id);
-                                       // If the selected page is not online, find the right ID
-                               $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
-                                       // The version of page:
-                               $verPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, 'pages', $onlineId);
-
-                               if (!$verPage) {
-
-                                       if (!count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $onlineId))) {
-                                               if ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0)) {
-
-                                                       $onClick = $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd[pages][' . $onlineId . '][version][action]=new&cmd[pages][' . $onlineId . '][version][treeLevels]=0',
-                                                               t3lib_div::linkThisScript(array(
-                                                                       'id' => $onlineId
-                                                               )));
-                                                       $onClick = 'window.location.href=\'' . $onClick . '\'; return false;';
-                                                               // Write out HTML code:
-                                                       return '
-
-                                                               <!--
-                                                                       No version yet, create one?
-                                                               -->
-                                                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                                                       <tr>
-                                                                               <td>' . $selectorLabel . '</td>
-                                                                               <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
-                                                                               <td>
-                                                                                       <input type="button" value="New version of page" name="_" onclick="' . htmlspecialchars($onClick) . '" /></td>
-                                                                       </tr>
-                                                               </table>
-                                                       ';
-                                               }
+                               // Get Current page record:
+                       $curPage = t3lib_BEfunc::getRecord('pages', $id);
+                               // If the selected page is not online, find the right ID
+                       $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
+                               // The version of page:
+                       $verPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, 'pages', $onlineId);
+
+                       if (!$verPage) {
+
+                               if (!count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $onlineId))) {
+                                       if ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0)) {
+
+                                               $onClick = $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd[pages][' . $onlineId . '][version][action]=new&cmd[pages][' . $onlineId . '][version][treeLevels]=0',
+                                                       t3lib_div::linkThisScript(array(
+                                                               'id' => $onlineId
+                                                       )));
+                                               $onClick = 'window.location.href=\'' . $onClick . '\'; return false;';
+                                                       // Write out HTML code:
+                                               return '
+
+                                                       <!--
+                                                               No version yet, create one?
+                                                       -->
+                                                       <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
+                                                               <tr>
+                                                                       <td>' . $selectorLabel . '</td>
+                                                                       <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
+                                                                       <td>
+                                                                               <input type="button" value="New version of page" name="_" onclick="' . htmlspecialchars($onClick) . '" /></td>
+                                                               </tr>
+                                                       </table>
+                                               ';
                                        }
-                               } elseif ($verPage['t3ver_swapmode']==0) {
-                                       $onClick = $GLOBALS['TBE_TEMPLATE']->issueCommand('&cmd[pages][' . $onlineId . '][version][action]=swap&cmd[pages][' .
-                                               $onlineId . '][version][swapWith]=' . $verPage['uid'],
-                                               t3lib_div::linkThisScript(array(
-                                                       'id' => $onlineId
-                                               )));
-                                       $onClick = 'window.location.href=\'' . $onClick . '\'; return false;';
-
-                                               // Write out HTML code:
-                                       return '
-
-                                               <!--
-                                                       Version selector:
-                                               -->
-                                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
-                                                       <tr>
-                                                               <td>' . $selectorLabel . '</td>
-                                                               <td>' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:workspace', TRUE) . ': "' . htmlspecialchars($wsTitle) . '"</td>
-                                                               <td>
-                                                                       <input type="button" value="' . $GLOBALS['LANG']->sL('LLL:EXT:version/locallang.xml:versionSelect.publish', TRUE) .
-                                                                               '" onclick="' . htmlspecialchars($onClick) . '" /></td>
-                                                       </tr>
-                                               </table>
-                                       ';
                                }
                        }
                }
index 12e024f..bc1aa7a 100644 (file)
@@ -893,11 +893,6 @@ class tx_version_tcemain {
                                                                                        $curVersion['t3ver_state'] = 0;
                                                                                }
 
-                                                                                       // Keeping the swapmode state
-                                                                               if ($table === 'pages') {
-                                                                                       $curVersion['t3ver_swapmode'] = $swapVersion['t3ver_swapmode'];
-                                                                               }
-
                                                                                        // Registering and swapping MM relations in current and swap records:
                                                                                $tcemainObj->version_remapMMForVersionSwap($table, $id, $swapWith);
 
@@ -971,37 +966,6 @@ class tx_version_tcemain {
                                                                                        $theLogId = $tcemainObj->log($table, $swapWith, 2, $propArr['pid'], 0, $label, 10, array($propArr['header'], $table . ':' . $swapWith), $propArr['event_pid']);
                                                                                        $tcemainObj->setHistory($table, $swapWith, $theLogId);
 
-                                                                                               // SWAPPING pids for subrecords:
-                                                                                       if ($table=='pages' && $swapVersion['t3ver_swapmode'] >= 0) {
-
-                                                                                                       // Collect table names that should be copied along with the tables:
-                                                                                               foreach ($GLOBALS['TCA'] as $tN => $tCfg) {
-                                                                                                               // For "Branch" publishing swap ALL,
-                                                                                                               // otherwise for "page" publishing, swap only "versioning_followPages" tables
-                                                                                                       if ($swapVersion['t3ver_swapmode'] > 0 || $GLOBALS['TCA'][$tN]['ctrl']['versioning_followPages']) {
-                                                                                                               $temporaryPid = -($id+1000000);
-
-                                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN, 'pid=' . intval($id), array('pid' => $temporaryPid));
-                                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                                                       $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                                                               }
-
-                                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN, 'pid=' . intval($swapWith), array('pid' => $id));
-                                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                                                       $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                                                               }
-
-                                                                                                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($tN, 'pid=' . intval($temporaryPid), array('pid' => $swapWith));
-                                                                                                               if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                                                                                                                       $sqlErrors[] = $GLOBALS['TYPO3_DB']->sql_error();
-                                                                                                               }
-
-                                                                                                               if (count($sqlErrors)) {
-                                                                                                                       $tcemainObj->newlog('During Swapping: SQL errors happened: ' . implode('; ', $sqlErrors), 2);
-                                                                                                               }
-                                                                                                       }
-                                                                                               }
-                                                                                       }
                                                                                                // Clear cache:
                                                                                        $tcemainObj->clear_cache($table, $id);
 
index 7bff439..0dd716a 100755 (executable)
@@ -817,16 +817,7 @@ class tx_version_cm1 extends t3lib_SCbase {
                                                        // Get the offline version record and icon:
                                                $rec_off = t3lib_BEfunc::getRecord($table, $rec['uid']);
 
-                                               // Prepare swap-mode values:
-                                               if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1) {
-                                                       if ($rec_off['t3ver_swapmode']>0) {
-                                                               $vType = 'branch';
-                                                       } else {
-                                                               $vType = 'page';
-                                                       }
-                                               } else {
-                                                       $vType = 'element';
-                                               }
+                                               $vType = 'element';
 
                                                // Get icon
                                                $icon = t3lib_iconWorks::getSpriteIconForRecord($table, $rec_off, array('title' => t3lib_BEfunc::getRecordIconAltText($rec_off, $table)));
@@ -873,10 +864,6 @@ class tx_version_cm1 extends t3lib_SCbase {
 
                                                        // Modify main cell based on first version shown:
                                                $subElements = array();
-                                               if ($table==='pages' && $rec_off['t3ver_swapmode']!=-1 && $mainCell)    {       // For "Page" and "Branch" swap modes where $mainCell is still carrying content (only first version)
-                                                       $subElements['on'] = $this->subElements($rec_on['uid'], $rec_off['t3ver_swapmode']);
-                                                       $subElements['off'] = $this->subElements($rec_off['uid'], $rec_off['t3ver_swapmode'], $rec_on['uid']);
-                                               }
                                                $mainCell = str_replace('###SUB_ELEMENTS###', $subElements['on'], $mainCell);
 
                                                        // Create version element:
index e41b164..2a42939 100755 (executable)
@@ -86,7 +86,7 @@ class wslib {
         * @param       integer         Lifecycle filter: 1 = select all drafts (never-published), 2 = select all published one or more times (archive/multiple), anything else selects all.
         * @param       integer         Stage filter: -99 means no filtering, otherwise it will be used to select only elements with that stage. For publishing, that would be "10"
         * @param       integer         Page id: Live page for which to find versions in workspace!
-        * @return      array           Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid, t3ver_oid and t3ver_swapmode fields. The REAL pid of the online record is found as "realpid"
+        * @return      array           Array of all records uids etc. First key is table name, second key incremental integer. Records are associative arrays with uid and t3ver_oid fields. The REAL pid of the online record is found as "realpid"
         */
        function selectVersionsInWorkspace($wsid, $filter = 0, $stage = -99, $pageId = -1) {
                $wsid = intval($wsid);
@@ -100,7 +100,7 @@ class wslib {
                                        // Select all records from this table in the database from the workspace
                                        // This joins the online version with the offline version as tables A and B
                                $recs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows (
-                                       'A.uid, A.t3ver_oid,'.($table==='pages' ? ' A.t3ver_swapmode,':'').' B.pid AS realpid',
+                                       'A.uid, A.t3ver_oid, B.pid AS realpid',
                                        $table.' A,'.$table.' B',
                                        'A.pid=-1'.     // Table A is the offline version and pid=-1 defines offline
                                                ($pageId!=-1 ? ($table==='pages' ? ' AND B.uid='.intval($pageId) : ' AND B.pid='.intval($pageId)) : '').