Skip to content

[4.0] Escape single quotes properly in postgres install file#28443

Merged
wilsonge merged 3 commits intojoomla:4.0-devfrom
Digital-Peak:j4/fix/postgres/install
Mar 25, 2020
Merged

[4.0] Escape single quotes properly in postgres install file#28443
wilsonge merged 3 commits intojoomla:4.0-devfrom
Digital-Peak:j4/fix/postgres/install

Conversation

@laoneo
Copy link
Copy Markdown
Member

@laoneo laoneo commented Mar 24, 2020

Summary of Changes

The install file for postgres is invalid, single quotes are not escaped properly.

It is also possible to escape it with (E'i\'m', 'en', 0),. What you guys prefer.

Testing Instructions

Install joomla with postgres.

Expected result

Installation goes through.

Actual result

Installation fails.

@richard67
Copy link
Copy Markdown
Member

@laoneo Please do the same changes in the update sql script postgresql/4.0.0-2018-07-29.sql, too.

@richard67
Copy link
Copy Markdown
Member

@laoneo Regarding your testing instructions: Here with PostgreSQL 11 installation doesn't fail without this PR, it just gives a lot of warnings in the log file of the postgresql server.

@richard67
Copy link
Copy Markdown
Member

@alikon What do you prefer for PostgreSQL? Escape E'i\'m' or 2 single quotes 'i''m' for string literal containing a single quote?

@richard67
Copy link
Copy Markdown
Member

richard67 commented Mar 24, 2020

@laoneo P.S. regarding update sql script postgresql/4.0.0-2018-07-29.sql: We can safely update it here because we don't support updates of 4 versions before beta.

@laoneo
Copy link
Copy Markdown
Member Author

laoneo commented Mar 24, 2020

Update file done.

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Mar 24, 2020

well if it is a matter of what i prefer than my preference goes to 'i''m'
i think is more easily readble

@richard67
Copy link
Copy Markdown
Member

richard67 commented Mar 24, 2020

Has both its advantages and disadvantages when doing a comparison between the joomla.sql files of the two database types to check if data is the same. Either you see an "E" at the beginning of a string or the additional single quote instead of a backslash in the middle of a string in the differences.

@richard67
Copy link
Copy Markdown
Member

I've just verified that we don't have the single quotes within strings elsewhere in sql, so we are free in our choice and don't need to be consistent with elsewhere, and I can confirm that this PR covers all occurrences.

@richard67
Copy link
Copy Markdown
Member

richard67 commented Mar 24, 2020

I have tested this item ✅ successfully on 59791d6

Hint for other testers: Different to what is described in section "Actual result", the installation worked here on PostgreSQL for me without the PR.

But there were lots of log entries like WARNING: nonstandard use of \' in a string literal at character ... in the postgresql server log file, and these disappear when having this PR applied.

There are many log entries like WARNING: nonstandard use of \\ in a string literal at character ... left in the postgresql server log file, so it seems we have elsewhere a problem with quoted backslashes in our sql. I would assume it is class paths in extensions table ;-) @laoneo Could you check that and if possible correct with another PR?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28443.

@richard67
Copy link
Copy Markdown
Member

@laoneo For the other issue with quoting backslash which I've mentioned in my testing result: Do you want to make a PR for that, or shall I do that?

@laoneo
Copy link
Copy Markdown
Member Author

laoneo commented Mar 24, 2020

Can you?

@richard67
Copy link
Copy Markdown
Member

I'll try, be patient.

@richard67
Copy link
Copy Markdown
Member

@laoneo It seems fixing the double backslash warnings would require to use the E'...' syntax. To be consistent then this PR would be better if using that syntax, too. But I am not 100% sure about that yet.

@richard67
Copy link
Copy Markdown
Member

Forget my previous post, this PR here is good as it is.

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Mar 25, 2020

@laoneo add change for finder.sql file see Digital-Peak#14

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Mar 25, 2020

I have tested this item ✅ successfully on 00e8113

tested on postgresql 11


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28443.

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Mar 25, 2020

we still have warning for the double/triple backslash, but matter for another pr

@richard67
Copy link
Copy Markdown
Member

I have tested this item ✅ successfully on 00e8113

Tested on PotsgreSQL 11.

The last change (file administrator/components/com_finder/sql/install.postgresql.sql) I've tested by review.

From my point of view this file is not really needed. Or is there a scenario in which com_finder has to be (re-)installed (normal install or discovery)? @wilsonge what do you think?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28443.

@richard67
Copy link
Copy Markdown
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/28443.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 25, 2020
@richard67
Copy link
Copy Markdown
Member

@alikon For the (double) backslashes I have prepared a branch for a PR, using the E'...' syntax for those strings which contain \/ or \\. You could see the changes here: 4.0-dev...richard67:4.0-dev-fix-double-backslash-warnings-postgresql.

That removes almost all of the warnings from the postgresql-11.log, but a few remain of which I haven't found the source yet. Maybe these come from database actions in PHP? If so, we would have a problem if we don't want to have database-specific statements (what would be a mess). So maybe we should set a session variable standard_conforming_strings=on? The changes in this PR here will still be correct then, but for the other backslashes we might be ok then without any other change? Can you check that? If necessary we can talk on Glip in the evenings or on weekend.

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Mar 25, 2020

i was playing on the same toy as you 😄
and i've the same conclusion as you

but a few remain of which I haven't found the source yet.

Yeah better to chat on Glip ......

@wilsonge wilsonge merged commit 0a6da70 into joomla:4.0-dev Mar 25, 2020
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Mar 25, 2020
@wilsonge wilsonge deleted the j4/fix/postgres/install branch March 25, 2020 10:48
@wilsonge
Copy link
Copy Markdown
Contributor

Thanks!

@wilsonge wilsonge added this to the Joomla 4.0 milestone Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants