Wir haben das Problem auch bei vielen Kunden mit Maria-DB und lösen das durch einen SQL-Fix in der Datenbank (.sh-Script, ihr benötigt Zugriff auf den Server z.B. mit ssh).
# Default variables
ENV_FILE=".env.local"
# Connect to db
DB_INITIALIZED=0
init_db_connection() {
if [ "$DB_INITIALIZED" -eq 1 ]; then
return
fi
if [ ! -f "$ENV_FILE" ]; then
echo "❌ $ENV_FILE not found"
exit 1
fi
DATABASE_URL=$(grep '^DATABASE_URL=' "$ENV_FILE" | cut -d '=' -f2-)
# Remove surrounding quotes from .env value
DATABASE_URL="${DATABASE_URL%\"}"
DATABASE_URL="${DATABASE_URL#\"}"
DATABASE_URL="${DATABASE_URL%\'}"
DATABASE_URL="${DATABASE_URL#\'}"
if [ -z "$DATABASE_URL" ]; then
echo "❌ DATABASE_URL not found in $ENV_FILE"
exit 1
fi
# Split URL
local CREDS_HOST_DB
CREDS_HOST_DB=$(echo "$DATABASE_URL" | sed 's|.*://||')
USER=$(echo "$CREDS_HOST_DB" | cut -d: -f1)
PASS=$(echo "$CREDS_HOST_DB" | cut -d: -f2 | cut -d@ -f1)
HOST=$(echo "$CREDS_HOST_DB" | cut -d@ -f2 | cut -d/ -f1)
DB=$(echo "$CREDS_HOST_DB" | cut -d/ -f2)
# Port optional
PORT=$(echo "$HOST" | grep -o ':[0-9]*' | tr -d ':')
HOST=$(echo "$HOST" | cut -d: -f1)
PORT=${PORT:-3306}
# Url decode
PASS=$(printf '%b' "${PASS//%/\\x}")
USER=$(printf '%b' "${USER//%/\\x}")
DB=$(printf '%b' "${DB//%/\\x}")
# Detect and validate the database type (MySQL or MariaDB) and store it in DBTYPE
DBTYPE=""
db_version_comment=$(mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASS" -e "SHOW VARIABLES LIKE 'version_comment';" 2>/dev/null | tail -n 1)
if echo "$db_version_comment" | grep -iq "mariadb"; then
DBTYPE="mariadb"
echo "Detected database type: MariaDB"
elif echo "$db_version_comment" | grep -iq "mysql"; then
DBTYPE="mysql"
echo "Detected database type: MySQL"
else
echo "$db_version_comment"
echo "❌ Error: Incorrect db type or db credentials are wrong! Allowed db types are: MySQL and MariaDB"
exit 1
fi
echo "🔌 DB ready: $DB@$HOST:$PORT (User: $USER)"
DB_INITIALIZED=1
}
# Fix for revocation request form: 6.6.10.14 to 6.7.0.0 and from 6.7.9.0
init_db_connection
if [ "$DBTYPE" == "mariadb" ]; then
echo "🩹 Patch db because of maria db problem with revocation request form"
VERSION_ID_HEX="0x0fa91ce3e96a4bc2be4bd9ce752c3425" # Constant LIVE_VERSION from /var/www/html/vendor/shopware/core/Defaults.php
# Get cms_page_id for the desired page
SQL_SELECT="SELECT cms_page_id FROM cms_page_translation WHERE name = 'Standard Shopseiten-Layout mit Formular für Widerrufsanträge';"
PAGE_ID=$(mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASS" "$DB" -N -B -e "$SQL_SELECT")
if [ -z "$PAGE_ID" ]; then
echo "❌ No cms_page_id found for the desired page."
else
SQL_UPDATE="
UPDATE cms_page SET version_id = $VERSION_ID_HEX WHERE id = '$PAGE_ID';
UPDATE cms_page_translation SET cms_page_version_id = $VERSION_ID_HEX WHERE cms_page_id = '$PAGE_ID';
UPDATE cms_section SET version_id = $VERSION_ID_HEX, cms_page_version_id = $VERSION_ID_HEX WHERE cms_page_id = '$PAGE_ID';
"
mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASS" "$DB" -e "$SQL_UPDATE"
# Get cms_section_id for the desired page
SQL_SELECT="SELECT id FROM cms_section WHERE cms_page_id = '$PAGE_ID';"
SECTION_ID=$(mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASS" "$DB" -N -B -e "$SQL_SELECT")
if [ -z "$SECTION_ID" ]; then
echo "❌ No cms_section_id found for the desired page."
else
SQL_UPDATE="UPDATE cms_block SET version_id = $VERSION_ID_HEX WHERE cms_section_id = '$SECTION_ID';"
mysql -h "$HOST" -P "$PORT" -u "$USER" -p"$PASS" "$DB" -e "$SQL_UPDATE"
echo "✅ Patch applied successfully."
fi
fi
fi
Das fixt bei uns das unsichtbare Widerrufsformular nach dem Update aber löst das eigentliche Problem nicht: Falsche Default-Werte in der Datenbank für version_id-Felder.