1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flarum_ynh.git synced 2024-09-03 18:36:24 +02:00

Merge pull request #205 from YunoHost-Apps/fix-ext-enabling

Fixes https://github.com/YunoHost-Apps/flarum_ynh/issues/204
This commit is contained in:
tituspijean 2023-01-08 16:24:41 +01:00 committed by GitHub
commit 43e5c4b18d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,9 +43,10 @@ activate_flarum_extension() {
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'" sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $database | tail -1) old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $database | tail -1)
# Append the extension name at the end of the list # Use jq to test presence of the extension in the list of enabled extensions
addition=",\"${short_extension}\"]" # if not, then add it.
new_extensions_enabled=${old_extensions_enabled::-1}$addition new_extensions_enabled=$(jq -jrc --arg short_extension 'if (any(index("$short_extension")) | not) then . |= + $short_extension else . end' <<< $old_extensions_enabled)
# Update activated extensions list # Update activated extensions list
sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';" sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';"
ynh_mysql_execute_as_root "$sql_command" $database ynh_mysql_execute_as_root "$sql_command" $database