mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-30 01:37:13 +02:00
swap hardcoded public values for DB_SCHEMA constant
This commit is contained in:
@ -49,6 +49,11 @@ if(!defined('PG4WP_ROOT')) {
|
||||
mkdir(PG4WP_LOG);
|
||||
}
|
||||
|
||||
// Default to public schema
|
||||
if (!defined('DB_SCHEMA')) {
|
||||
define('DB_SCHEMA', 'public');
|
||||
}
|
||||
|
||||
// Here happens all the magic
|
||||
require_once(PG4WP_ROOT . '/core.php');
|
||||
} // Protection against multiple loading
|
||||
|
@ -6,7 +6,7 @@ class DescribeSQLRewriter extends AbstractSQLRewriter
|
||||
{
|
||||
$sql = $this->original();
|
||||
$table = $this->extractTableName($sql);
|
||||
return $this->generatePostgresDescribeTable($table);
|
||||
return $this->generatePostgresDescribeTable($table, DB_SCHEMA);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ class DescribeSQLRewriter extends AbstractSQLRewriter
|
||||
* @param string $schema The schema name
|
||||
* @return string The generated SQL query
|
||||
*/
|
||||
public function generatePostgresDescribeTable($tableName, $schema = "public")
|
||||
public function generatePostgresDescribeTable($tableName, $schema)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT
|
||||
|
@ -37,7 +37,7 @@ class SelectSQLRewriter extends AbstractSQLRewriter
|
||||
if(false !== strpos($sql, 'information_schema')) {
|
||||
// WP Site Health rewrites
|
||||
if (false !== strpos($sql, "SELECT TABLE_NAME AS 'table', TABLE_ROWS AS 'rows', SUM(data_length + index_length)")) {
|
||||
$sql = $this->postgresTableSizeRewrite();
|
||||
$sql = $this->postgresTableSizeRewrite(DB_SCHEMA);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
@ -373,7 +373,7 @@ class SelectSQLRewriter extends AbstractSQLRewriter
|
||||
}
|
||||
|
||||
// This method is specifically to handle should_suggest_persistent_object_cache in wp site health
|
||||
protected function postgresTableSizeRewrite($schema = 'public')
|
||||
protected function postgresTableSizeRewrite($schema)
|
||||
{
|
||||
|
||||
$sql = <<<SQL
|
||||
|
@ -6,7 +6,7 @@ class ShowFullColumnsSQLRewriter extends AbstractSQLRewriter
|
||||
{
|
||||
$sql = $this->original();
|
||||
$table = $this->extractTableNameFromShowColumns($sql);
|
||||
return $this->generatePostgresShowColumns($table);
|
||||
return $this->generatePostgresShowColumns($table, DB_SCHEMA);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ class ShowFullColumnsSQLRewriter extends AbstractSQLRewriter
|
||||
* @param string $schema The schema name
|
||||
* @return string The generated SQL query
|
||||
*/
|
||||
public function generatePostgresShowColumns($tableName, $schema = "public")
|
||||
public function generatePostgresShowColumns($tableName, $schema)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT
|
||||
|
@ -5,7 +5,7 @@ class ShowTableStatusSQLRewriter extends AbstractSQLRewriter
|
||||
public function rewrite(): string
|
||||
{
|
||||
$sql = $this->original();
|
||||
return $this->generatePostgresShowTableStatus();
|
||||
return $this->generatePostgresShowTableStatus(DB_SCHEMA);
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ class ShowTableStatusSQLRewriter extends AbstractSQLRewriter
|
||||
*
|
||||
* @return string The generated SQL query
|
||||
*/
|
||||
public function generatePostgresShowTableStatus($schema = "public")
|
||||
public function generatePostgresShowTableStatus($schema)
|
||||
{
|
||||
$sql = <<<SQL
|
||||
SELECT
|
||||
|
@ -4,7 +4,7 @@ class ShowTablesSQLRewriter extends AbstractSQLRewriter
|
||||
{
|
||||
public function rewrite(): string
|
||||
{
|
||||
$schema = "public";
|
||||
$schema = DB_SCHEMA;
|
||||
return 'SELECT tablename FROM pg_tables WHERE schemaname = \'$schema\';';
|
||||
}
|
||||
}
|
||||
|
19
readme.md
19
readme.md
@ -68,6 +68,25 @@ This is because the database needs to be up and running before any plugin can be
|
||||
|
||||
1. Point your Web Browser to your WordPress installation and go through the traditional WordPress installation routine.
|
||||
|
||||
wp-config constants you can set
|
||||
```
|
||||
// ** Database settings - You can get this info from your web host ** //
|
||||
/** The name of the database for WordPress */
|
||||
define( 'DB_NAME', 'database_name_here' );
|
||||
|
||||
/** Database username */
|
||||
define( 'DB_USER', 'username_here' );
|
||||
|
||||
/** Database password */
|
||||
define( 'DB_PASSWORD', 'password_here' );
|
||||
|
||||
/** Database hostname */
|
||||
define( 'DB_HOST', 'localhost' );
|
||||
|
||||
/** PG4WP specific Database schema / search path */
|
||||
define( 'DB_SCHEMA', 'public' );
|
||||
```
|
||||
|
||||
|
||||
### Contributing
|
||||
|
||||
|
Reference in New Issue
Block a user