Skip to content

Commit 0a498c9

Browse files
committed
1.0.0.beta.18
Fix #11. Danke an https://github.com/godsdog
1 parent 83bdfb5 commit 0a498c9

3 files changed

Lines changed: 44 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33

44
Dieses Changelog wird ab Version `1.0.0` neu geführt.
55

6+
## v1.0.0.beta.18 (08. Juni 2026)
7+
8+
### Fixed
9+
- Frontend-Fehler für nicht eingeloggte Besucher behoben: `Session not started, call rex_login::startSession() before!`.
10+
- `DomainConfig::getActiveDomainId()` greift im Frontend nicht mehr auf `rex_session()` / `rex_set_session()` zu.
11+
- Aktive Domain wird im Frontend über `rex_yrewrite::getCurrentDomain()` ermittelt.
12+
13+
### Improved
14+
- `domainExists()` in `DomainConfig` prüft YRewrite-Verfügbarkeit und fängt SQL-Fehler robust ab.
15+
616
## 2026-06-02
717

818
### Added

lib/DomainConfig.php

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,38 @@ public static function getActiveDomainId(): int
3333
// Prüfe URL-Parameter
3434
$requested = \rex_request('domain_id', 'int', 0);
3535
if ($requested > 0 && self::domainExists($requested)) {
36-
\rex_set_session(self::SESSION_KEY, $requested);
36+
if (\rex::isBackend()) {
37+
\rex_set_session(self::SESSION_KEY, $requested);
38+
}
3739
return $requested;
3840
}
3941

40-
// Prüfe Session
41-
$sessionDomainId = (int) \rex_session(self::SESSION_KEY, 'int', 0);
42-
if ($sessionDomainId > 0 && self::domainExists($sessionDomainId)) {
43-
return $sessionDomainId;
42+
// Frontend: ohne Session arbeiten (verhindert Fehler bei nicht eingeloggten Besuchern)
43+
if (!\rex::isBackend()) {
44+
if (\rex_addon::get('yrewrite')->isAvailable() && class_exists('rex_yrewrite')) {
45+
$currentDomain = \rex_yrewrite::getCurrentDomain();
46+
if ($currentDomain && method_exists($currentDomain, 'getId')) {
47+
$currentDomainId = (int) $currentDomain->getId();
48+
if ($currentDomainId > 0) {
49+
return $currentDomainId;
50+
}
51+
}
52+
}
53+
} else {
54+
// Backend: Session-Auswahl berücksichtigen
55+
$sessionDomainId = (int) \rex_session(self::SESSION_KEY, 'int', 0);
56+
if ($sessionDomainId > 0 && self::domainExists($sessionDomainId)) {
57+
return $sessionDomainId;
58+
}
4459
}
4560

4661
// Fallback zur ersten Domain
4762
$domains = self::getDomains();
4863
if (!empty($domains)) {
4964
$fallbackDomainId = (int) $domains[0]['id'];
50-
\rex_set_session(self::SESSION_KEY, $fallbackDomainId);
65+
if (\rex::isBackend()) {
66+
\rex_set_session(self::SESSION_KEY, $fallbackDomainId);
67+
}
5168
return $fallbackDomainId;
5269
}
5370

@@ -70,9 +87,17 @@ public static function getActiveDomain(): ?array
7087

7188
public static function domainExists(int $domainId): bool
7289
{
90+
if (!\rex_addon::get('yrewrite')->isAvailable()) {
91+
return false;
92+
}
93+
7394
$sql = \rex_sql::factory();
74-
$sql->setQuery('SELECT id FROM ' . \rex::getTable('yrewrite_domain') . ' WHERE id = ?', [$domainId]);
75-
return $sql->getRows() > 0;
95+
try {
96+
$sql->setQuery('SELECT id FROM ' . \rex::getTable('yrewrite_domain') . ' WHERE id = ?', [$domainId]);
97+
return $sql->getRows() > 0;
98+
} catch (\rex_sql_exception $e) {
99+
return false;
100+
}
76101
}
77102

78103
public static function renderDomainTabs(int $activeDomainId): string

package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package: jsonld_manager
2-
version: '1.0.0.beta.17'
2+
version: '1.0.0.beta.18'
33
author: 'Friends Of REDAXO'
44
supportpage: https://github.com/FriendsOfREDAXO/jsonld_manager
55

0 commit comments

Comments
 (0)