Closed loiczam closed 2 months ago
This issue does not look like a regression or issue with Yii framework code, but intended behavior.
It's correct that Yii does not allow overriding the DEFAULT_SCHEMA const (public
). If your table resides in another schema, you should alter the calling code and specify schema plus table name (ie: myschema.mytable
). Then the property $schemaName will be set as expected on the table class. (through https://github.com/LimeSurvey/LimeSurvey/blob/master/vendor/yiisoft/yii/framework/db/schema/pgsql/CPgsqlSchema.php#L144)
A) Initial bug observation. The manual installation of the latest version of LimeSurvey v6.5.x with PostgreSQL 14 on Rocky Linux 8.10 and PHP 8.3 should normally proceed without issues, as LimeSurvey is officially compatible with PostgreSQL, just like MSSQL or MySQL.
The initial tests of manual or console installation failed because an error message identical to the forum post below appeared: "LimeSurvey table settings_global not found in database" even though the configuration is correct.
Forum Post
In essence, this means that despite correct configuration, the PHP -> PGSQL driver is not working because it cannot find a table that exists.
B) Initial code review. According to the LimeSurvey forum, PGSQL schemas could be the root cause. To investigate this bug, we delved into the code:
GitHub Link resolveTableNames($table, $name) (Line 149) sets the schema to the value DEFAULT_SCHEMA if the table name is not in the format databasename.tablename.
Tracing it further, we arrive at the calling function:
GitHub Link loadTable($name)
The variable $table is an object of type CPgsqlTableSchema.
The declaration of the CPgsqlTableSchema object...
GitHub Link
... adds to the inherited object the public variable $schemaName without initializing it or providing a method to modify it. I note that this value is later read directly in CPgsqlTableSchema. Its value and type are not initialized, and this value is likely set to NULL by PHP. This code effectively configures the SCHEMA to DEFAULT_SCHEMA automatically, without allowing for modification.
CPgsqlTableSchema overrides the CDbTableSchema class, which is generic across all database drivers in the Yii framework. This class does not mention schemas.
Let me know if you need further modifications or clarifications!