Commit 424a896a authored by Kevin Ditscheid's avatar Kevin Ditscheid

[BUGFIX] Fix broken languagevisibility flag remains in sys_refindex

parent 67e9106a
......@@ -347,7 +347,7 @@ class TceMainHook {
$languageId = (int) $incomingFieldArray['record_language_uid'];
}
$pid = -1;
$pid = 0;
if (isset($incomingFieldArray['pid'])) {
$pid = (int) $incomingFieldArray['pid'];
}
......
......@@ -28,6 +28,7 @@ namespace TYPO3\Languagevisibility\Repository;
use Doctrine\DBAL\DBALException;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -173,13 +174,11 @@ class VisibilityFlagRepository implements SingletonInterface {
* @return void
*/
public function removeFlagsByTableAndPid($table, $pid): void {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_languagevisibility_visibility_flag'
);
$queryBuilder
->delete('tx_languagevisibility_visibility_flag')
$result = $queryBuilder->select('uid')
->from('tx_languagevisibility_visibility_flag')
->where(
$queryBuilder->expr()->eq(
'pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)
......@@ -191,6 +190,13 @@ class VisibilityFlagRepository implements SingletonInterface {
)
)
->execute();
$rows = $result->fetchAll();
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler->start([], []);
foreach ($rows as $row) {
$dataHandler->deleteAction('tx_languagevisibility_visibility_flag', $row['uid']);
}
}
/**
......@@ -202,12 +208,17 @@ class VisibilityFlagRepository implements SingletonInterface {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_languagevisibility_visibility_flag'
);
$queryBuilder
->delete('tx_languagevisibility_visibility_flag')
$result = $queryBuilder->select('uid')
->from('tx_languagevisibility_visibility_flag')
->where(
$queryBuilder->expr()->eq('flag', $queryBuilder->createNamedParameter('active'))
)
->execute();
$rows = $result->fetchAll();
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$dataHandler->start([], []);
foreach ($rows as $row) {
$dataHandler->deleteAction('tx_languagevisibility_visibility_flag', $row['uid']);
}
}
}
......@@ -76,12 +76,16 @@ class FieldVisibilityUserFunction extends AbstractFormElement {
//init some class attributes
$pageId = $this->data['effectivePid'];
$uid = $this->data['databaseRow']['uid'];
$row = $this->data['databaseRow'];
//use the effectivePid as the databaserow pid instead of the "sorting" pid
$row['pid'] = $pageId;
if (strpos($uid, 'NEW') === 0) {
$this->isNewElement = TRUE;
}
if ($this->data['tableName'] === 'pages' && !$this->isNewElement) {
$pageId = $this->data['databaseRow']['uid'];
$pageId = $row['uid'];
}
/** @var BackendUserAuthentication $backendUser */
......@@ -114,17 +118,17 @@ class FieldVisibilityUserFunction extends AbstractFormElement {
$elementfactory = GeneralUtility::makeInstance(ElementFactory::class);
$value = $this->data['databaseRow'][$this->data['fieldName']];
$value = $row[$this->data['fieldName']];
$table = $this->data['tableName'];
$isOverlay = BackendServices::isOverlayRecord($this->data['databaseRow'], $table);
$isOverlay = BackendServices::isOverlayRecord($row, $table);
$this->data['databaseRow'][$GLOBALS['TCA'][$table]['ctrl']['languageField']] = (int) $this->data['databaseRow'][$GLOBALS['TCA'][$table]['ctrl']['languageField']][0];
$this->data['databaseRow'][$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = (int) $this->data['databaseRow'][$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']][0];
$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] = (int) $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']][0];
$row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = (int) $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']][0];
try {
//This element is an original element (no overlay)
/** @var Element $originalElement */
$originalElement = $elementfactory->getElementForTable($table, $this->data['databaseRow']);
$originalElement = $elementfactory->getElementForTable($table, $row);
} catch (Exception $exception) {
$result['html'] = '<div class="alert alert-danger">' .
$this->getLLL('backend.error.elementNotSupported') . '</div>';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment