Skip to content

Conversation

obel1x
Copy link

@obel1x obel1x commented Nov 23, 2022

Make setup accept unix- sockets without the need to contain ':' in the name.

Summary

Makes it possible to enter fully qualified unix- socket- filenames as Database-Host in setup.

Checklist

could be better next time... think its intuitive to use and works.

@obel1x obel1x changed the title Setup: Databasehost may be a unix-socket Setup: Databasehost may be an unix-socket Nov 23, 2022
@kesselb
Copy link
Collaborator

kesselb commented Nov 23, 2022

It is already possible to use a format localhost:filename, which didn't seem to be self explaining to me as this is not a common annotation and is not mentioned anywhere.

/**
* Your host server name, for example ``localhost``, ``hostname``,
* ``hostname.example.com``, or the IP address. To specify a port use
* ``hostname:####``; to specify a Unix socket use
* ``/path/to/directory/containing/socket`` e.g. ``/run/postgresql/``.
*/
'dbhost' => '',

Hi, I agree our documention is a bit vague about it.
Please add your new syntax to config.sample.php.

@szaimen szaimen added this to the Nextcloud 26 milestone Nov 23, 2022
@szaimen szaimen added enhancement 3. to review Waiting for reviews labels Nov 23, 2022
@szaimen szaimen requested review from a team, blizzz, icewind1991 and juliusknorr and removed request for a team November 23, 2022 22:27
@obel1x
Copy link
Author

obel1x commented Nov 24, 2022

It is already possible to use a format localhost:filename, which didn't seem to be self explaining to me as this is not a common annotation and is not mentioned anywhere.

/**
* Your host server name, for example ``localhost``, ``hostname``,
* ``hostname.example.com``, or the IP address. To specify a port use
* ``hostname:####``; to specify a Unix socket use
* ``/path/to/directory/containing/socket`` e.g. ``/run/postgresql/``.
*/
'dbhost' => '',

Hi, I agree our documention is a bit vague about it. Please add your new syntax to config.sample.php.

I don't understand. The file already contains that syntax as you can see - it is just not working that way without my change. Thats why i changed it to work like its written there.

Edit: Oh wait, maybe this is a missunderstanding. My change is covering the INITIAL SETUP DIALOG which is showing up at the first start, before the DB has been set up. It makes it possible to enter values as documented there.

@PVince81 PVince81 requested a review from kesselb December 16, 2022 16:06
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kesselb
Copy link
Collaborator

kesselb commented Dec 17, 2022

Hi @obel1x, thanks again for your pull request 👍

Could you please

Have a pleasant week ✌️

@obel1x
Copy link
Author

obel1x commented Dec 18, 2022

Thank you. i did as you said... after push, there were many differences, so i synced again. Hope now everything is fine

@kesselb
Copy link
Collaborator

kesselb commented Dec 18, 2022

Index: lib/private/Setup/AbstractDatabase.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/private/Setup/AbstractDatabase.php b/lib/private/Setup/AbstractDatabase.php
--- a/lib/private/Setup/AbstractDatabase.php	(revision 26eb0e8b7720616e0b30eca98e50abb509f5beb6)
+++ b/lib/private/Setup/AbstractDatabase.php	(date 1671396664081)
@@ -134,9 +134,9 @@
 			}
 			$connectionParams['host'] = $host;
 		} elseif (strpos($this->dbHost, '/') >= 0) {
-		    // Host variable may only be an unix socket.
-            $connectionParams['unix_socket'] = $this->dbHost;
-		    $connectionParams['host'] = 'localhost';
+			// Host variable may only be an unix socket.
+			$connectionParams['unix_socket'] = $this->dbHost;
+			$connectionParams['host'] = 'localhost';
 		}
 
 		$connectionParams = array_merge($connectionParams, $configOverwrite);

The linter is unhappy. Above patch should fix the linter warnings.
If you have a local development setup you can also run composer cs:fix.

@obel1x
Copy link
Author

obel1x commented Dec 19, 2022

what the hack... sorry eclipse. now better?

@kesselb
Copy link
Collaborator

kesselb commented Dec 19, 2022

Linter should be fine now but the sign off for the commits is missing.

git rebase HEAD~3 --signoff
git push --force-with-lease origin master

(to sign off the last 3 commits and push the changes)

@obel1x
Copy link
Author

obel1x commented Dec 20, 2022

ok, sorry, have not rebased anything before. That has not worked as expected. Also the signature is wrong, don't know how to set it right. think i have to read about signing and come back to this later.

@kesselb
Copy link
Collaborator

kesselb commented Dec 21, 2022

@obel1x Thank you 👍

It's a bit tricky with forks 😕

Your fork seems a bit out of sync.

I guess it should work to reset your fork to be even with nextcloud/server and apply the patch again: https://github.com/nextcloud/server/commit/3f79a2223502350861d61cbfb5f1a1f526521672.diff

If you prefer I can take your patch and resubmit here.

@obel1x obel1x closed this Dec 26, 2022
@obel1x obel1x mentioned this pull request Dec 26, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In the initial setup, entering an UNIX socket for the database host returns error

4 participants