Explorar o código

Select the first table which is not prefixed as wp_

Girish Ramakrishnan %!s(int64=7) %!d(string=hai) anos
pai
achega
5d103938d5
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      start.sh

+ 3 - 2
start.sh

@@ -4,8 +4,9 @@ set -eu
 
 readonly WP="/app/code/wp --allow-root"
 
-# Detect the wordpress prefix from existing database
-table_prefix=$(mysql --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} --host=${MYSQL_HOST} ${MYSQL_DATABASE} -e 'SHOW TABLES' --batch 2>/dev/null | sed -n 's/\(.*_\)usermeta/\1/p')
+# Detect the wordpress prefix from existing database. This is a bit of a hack because some wordpress plugins
+# seem to leave the old wp_ tables behind.
+table_prefix=$(mysql --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} --host=${MYSQL_HOST} ${MYSQL_DATABASE} -e 'SHOW TABLES' --batch 2>/dev/null | sed -n 's/\(.*_\)usermeta/\1/p' | grep -v ^wp_ | head -n1)
 [[ -n "${table_prefix}" ]] || table_prefix="wp_"
 echo "Using table prefix ${table_prefix}"