typo3_core_respect_language_all_when_generation_unique_slug.patch

Johannes Ender, 2020-01-10 08:30

Download (2.65 KB)

View differences:

Classes/DataHandling/SlugHelper.php (date 1568188868694)
250 250
        $this->applySlugConstraint($queryBuilder, $slug);
251 251
        $this->applyPageIdConstraint($queryBuilder, $pageId);
252 252
        $this->applyRecordConstraint($queryBuilder, $recordId);
253
        $this->applyLanguageConstraint($queryBuilder, $languageId);
253
        if ($languageId != -1) {
254
            $this->applyLanguageConstraint($queryBuilder, [-1, $languageId]);
255
        }
254 256
        $this->applyWorkspaceConstraint($queryBuilder);
255 257
        $statement = $queryBuilder->execute();
256 258

  
......
287 289
        $queryBuilder = $this->createPreparedQueryBuilder();
288 290
        $this->applySlugConstraint($queryBuilder, $slug);
289 291
        $this->applyRecordConstraint($queryBuilder, $recordId);
290
        $this->applyLanguageConstraint($queryBuilder, $languageId);
292
        if ($languageId != -1) {
293
            $this->applyLanguageConstraint($queryBuilder, [-1, $languageId]);
294
        }
291 295
        $this->applyWorkspaceConstraint($queryBuilder);
292 296
        $statement = $queryBuilder->execute();
293 297

  
......
431 435

  
432 436
    /**
433 437
     * @param QueryBuilder $queryBuilder
434
     * @param int $languageId
438
     * @param int|array $languageId
435 439
     */
436
    protected function applyLanguageConstraint(QueryBuilder $queryBuilder, int $languageId)
440
    protected function applyLanguageConstraint(QueryBuilder $queryBuilder, $languageId)
437 441
    {
438 442
        $languageFieldName = $GLOBALS['TCA'][$this->tableName]['ctrl']['languageField'] ?? null;
439 443
        if (!is_string($languageFieldName)) {
......
441 445
        }
442 446

  
443 447
        // Only check records of the given language
444
        $queryBuilder->andWhere(
445
            $queryBuilder->expr()->eq(
446
                $languageFieldName,
447
                $queryBuilder->createNamedParameter($languageId, \PDO::PARAM_INT)
448
            )
449
        );
448
        if (is_array($languageId)) {
449
            $queryBuilder->andWhere(
450
                $queryBuilder->expr()->in(
451
                    $languageFieldName,
452
                    $queryBuilder->createNamedParameter($languageId, Connection::PARAM_INT_ARRAY)
453
                )
454
            );
455
        } else {
456
            $queryBuilder->andWhere(
457
                $queryBuilder->expr()->eq(
458
                    $languageFieldName,
459
                    $queryBuilder->createNamedParameter($languageId, \PDO::PARAM_INT)
460
                )
461
            );
462
        }
450 463
    }
451 464

  
452 465
    /**