Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: servername auch im title tag im backend fragment ergänzt #132

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion fragments/maintenance/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Maintenance</title>
<title>
<?php
if (rex_addon::get('yrewrite')->isAvailable() && rex_yrewrite::getCurrentDomain()->getName() !== '') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (rex_addon::get('yrewrite')->isAvailable() && rex_yrewrite::getCurrentDomain()->getName() !== '') {
if (rex_addon::get('yrewrite')->isAvailable() && rex_yrewrite::getCurrentDomain()->getName() !== null) {

@alxndr-w Wir hatten es Ja neulich im Slack darüber ob getName() auch Null zurückgeben kann. Dann würde es eventuell sinn machen, anstatt auf leer, auf null zu prüfen.

Wie siehst du das?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (rex_addon::get('yrewrite')->isAvailable() && rex_yrewrite::getCurrentDomain()->getName() !== '') {
if (rex_addon::get('yrewrite')->isAvailable() && rex_yrewrite::getCurrentDomain() !== null && rex_yrewrite::getCurrentDomain()->getName() !== '') {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oder so.. doppelt hält besser ;)

Copy link
Member

@alxndr-w alxndr-w Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So meinte ich. Du musst sicherstellen, dass bei rex_yrewrite::getCurrentDomain() auch wirklich ein Objekt zurückkommt, bevor du die Methode ->getName() ausführen kannst.

Bzw. es gibt auch noch eine andere Schreibweise:
rex_yrewrite::getCurrentDomain()?->getName()
^

ich weiß nicht, ob die bereits in PHP 8.1 verfügbar ist. Hier könntest du mal recherchieren:

https://stitcher.io/blog/php-8-nullsafe-operator

Copy link
Contributor Author

@crydotsnake crydotsnake Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kam wohl mit PHP 8.0 hinzu: https://php.watch/versions/8.0/null-safe-operator

Dann gibt es diese auch mit PHP 8.1 und Höher.

echo rex_yrewrite::getCurrentDomain()->getName();
} else {
echo rex::getServerName();
}
?> - Maintenance
</title>
<style type="text/css">
html, body {
height: 100%;
Expand Down
10 changes: 9 additions & 1 deletion fragments/maintenance/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?= rex::getServerName() ?> - Maintenance</title>
<title>
<?php
if (rex_addon::get('yrewrite')->isAvailable() && rex_yrewrite::getCurrentDomain()->getName() !== '') {
echo rex_yrewrite::getCurrentDomain()->getName();
} else {
echo rex::getServerName();
}
?> - Maintenance
</title>
<link rel="stylesheet" href="<?= rex_url::addonAssets('maintenance', 'css/maintenance-frontend.css') ?>" />
</head>
<body>
Expand Down