pydio / pydio-core

Pydio 8 official repository
https://pydio.com
GNU Affero General Public License v3.0
867 stars 289 forks source link

SQLite: deleteRepository error #779

Closed mincowski closed 9 years ago

mincowski commented 9 years ago

Hello,

some time ago, I reported a problem related to deleting a sharing link when using SQLite. This problem still exists in 6.0.

After some testing, it seems that the following section in class.sqlConfDriver.php causes this.

switch ($this->sqlDriver["driver"]) {
    case "sqlite":
    case "sqlite3":
    case "postgre":
        dibi::nativeQuery("SET bytea_output=escape");
        $children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [searchable_repositories] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
        break;
    case "mysql":
        $children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [serial_role] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
    break;

Calling dibi::nativeQuery("SET bytea_output=escape"); on an SQLite database throws an error and (I am no db-expert) seems to be required only for Postgre.

Adjusting the case structure solved the problem for me.

switch ($this->sqlDriver["driver"]) {
    case "postgre":
        dibi::nativeQuery("SET bytea_output=escape");
    case "sqlite":
    case "sqlite3":
        $children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [searchable_repositories] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
        break;
    case "mysql":
        $children_results = dibi::query('SELECT * FROM [ajxp_roles] WHERE [serial_role] LIKE %~like~ GROUP BY [role_id]', '"'.$repositoryId.'";s:');
    break;

My question now is if the way it is is the intended behaviour or if these changes could be expected to cause other problems?

cdujeu commented 9 years ago

very probably a bug, will reproduce and fix it following your suggestion. thx