Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(New Global) Search URL broken for contacts app #1852

Closed
michaelof opened this issue Oct 14, 2020 · 25 comments · Fixed by #1972
Closed

(New Global) Search URL broken for contacts app #1852

michaelof opened this issue Oct 14, 2020 · 25 comments · Fixed by #1972
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working high High priority

Comments

@michaelof
Copy link

michaelof commented Oct 14, 2020

Steps to reproduce

  1. click on new global search
  2. enter any string, to get an ex. contact as offered match
  3. click on any contact
  4. HTTP 404 is thrown

Expected behaviour

contact details should be shown, of course :-)

Actual behaviour

HTTP/404. It seems to me, that final URL is malformed:
CURRENT: "https://hostname/apps/contacts/...."
instead of "https://hostname/index.php/apps/contacts/..."

Tried to add the missing .../index.php/... part manually in Browser's URL field, works, contact details are shown

Server configuration detail

Operating system: Linux 5.3.18-lp152.44-default #1 SMP Wed Sep 30 18:51:43 UTC 2020 (914f31e) x86_64

Webserver: Apache (apache2handler)

Database: mysql 10.4.14

PHP version:

7.4.6
Modules loaded: Core, date, libxml, pcre, filter, hash, Reflection, SPL, session, SimpleXML, standard, xml, mysqlnd, apache2handler, apcu, bcmath, bz2, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, gmp, iconv, imagick, intl, json, ldap, exif, mysqli, openssl, pcntl, PDO, pdo_mysql, pdo_sqlite, zlib, posix, soap, sockets, sqlite3, tokenizer, xmlreader, xmlwriter, zip, Phar, Zend OPcache

Nextcloud version: 20.0.0 - 20.0.0.9

Updated from an older Nextcloud/ownCloud or fresh install: updated regularily, base was OwnCloud long ago

Where did you install Nextcloud from: RPM from OpenSUSE repos

Signing status

Array
(
)

List of activated apps
Enabled:
 - accessibility: 1.6.0
 - activity: 2.13.1
 - admin_audit: 1.10.0
 - bruteforcesettings: 2.0.1
 - calendar: 2.1.2
 - cloud_federation_api: 1.3.0
 - comments: 1.10.0
 - contacts: 3.4.0
 - contactsinteraction: 1.1.0
 - dashboard: 7.0.0
 - dav: 1.16.0
 - encryption: 2.8.1
 - federatedfilesharing: 1.10.1
 - federation: 1.10.1
 - files: 1.15.0
 - files_external: 1.11.1
 - files_pdfviewer: 2.0.1
 - files_rightclick: 0.17.0
 - files_sharing: 1.12.0
 - files_trashbin: 1.10.1
 - files_versions: 1.13.0
 - files_videoplayer: 1.9.0
 - firstrunwizard: 2.9.0
 - issuetemplate: 0.7.0
 - logreader: 2.5.0
 - lookup_server_connector: 1.8.0
 - mail: 1.5.0
 - nextcloud_announcements: 1.9.0
 - notifications: 2.8.0
 - oauth2: 1.8.0
 - password_policy: 1.10.1
 - photos: 1.2.0
 - privacy: 1.4.0
 - provisioning_api: 1.10.0
 - recommendations: 0.8.0
 - serverinfo: 1.10.0
 - settings: 1.2.0
 - sharebymail: 1.10.0
 - spreed: 10.0.0
 - support: 1.3.0
 - survey_client: 1.8.0
 - systemtags: 1.10.0
 - tasks: 0.13.4
 - text: 3.1.0
 - theming: 1.11.0
 - twofactor_backupcodes: 1.9.0
 - twofactor_totp: 5.0.0
 - updatenotification: 1.10.0
 - user_status: 1.0.0
 - viewer: 1.4.0
 - weather_status: 1.0.0
 - workflowengine: 2.2.0
Disabled:
 - audioplayer
 - music
 - user_ldap

Configuration (config/config.php)
{
    "updatechecker": false,
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "localhost:10080",
***REMOVED SENSITIVE VALUE***",
***REMOVED SENSITIVE VALUE***",
***REMOVED SENSITIVE VALUE***"
    ],
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "overwrite.cli.url": "http:\/\/localhost:10080\/nextcloud",
    "dbtype": "mysql",
    "version": "20.0.0.9",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbtableprefix": "oc_",
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "logtimezone": "UTC",
    "installed": true,
    "mail_smtpmode": "sendmail",
    "mail_smtpsecure": "tls",
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "maintenance": false,
    "appstore.experimental.enabled": true,
    "theme": "",
    "loglevel": 0,
    "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
    "log_rotate_size": 10485760,
    "app_install_overwrite": [
        "tasks",
        "contacts",
        "unsplash",
        "bruteforcesettings"
    ],
    "mysql.utf8mb4": true,
    "encryption.legacy_format_support": true,
    "encryption.key_storage_migrated": false
}

Are you using external storage, if yes which one:

Are you using encryption: 1

Are you using an external user-backend, if yes which one:

Client configuration

Browser: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Operating system: OpenSUSE Leap 15.2

Logs

Web server error log
HTTP 404
Nextcloud log
none
Browser log

out of scope

@michaelof michaelof added 0. to triage Pending approval or rejection. This issue is pending approval. bug Something isn't working labels Oct 14, 2020
@michaelof
Copy link
Author

FYI contacts app in use is v 3.4.0

@call-me-matt
Copy link
Member

call-me-matt commented Oct 15, 2020

For me the search works fine. linked addresses are different for contact search and unified search, but both work (also v3.4.0):

contact-search

@skjnldsv
Copy link
Member

Yes, it is broken when pretty url is not enabled (aka showing index.php) :)

It seems to be related to the php function used to generate the route https://github.com/nextcloud/server/blob/2a054e6c04e0a40421510eb889cbf59f153c5177/apps/dav/lib/Search/ContactsSearchProvider.php#L184-L188

@octavsly
Copy link

octavsly commented Oct 15, 2020

have the same issue:

BROKEN: https://<server>/apps/contacts/All%20contacts/24cb27c7-842c-4701-8faf-d7826c728d45\~contacts
CORRECT : https://<server>/index.php/apps/contacts/All%20contacts/24cb27c7-842c-4701-8faf-d7826c728d45~contacts

I have fixed it by changing in:
apps/contacts/lib/Controller/ContactsController.php
line 62 from
$url = $this->urlGenerator->getAbsoluteURL('apps/contacts/' . $this->l10n->t('All contacts') . '/' . $contact);
to
$url = $this->urlGenerator->getAbsoluteURL('index.php/apps/contacts/' . $this->l10n->t('All contacts') . '/' . $contact);

@skjnldsv
Copy link
Member

@octavsly you should probably configure your nextcloud server correctly so it supports pretty urls :)
https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#pretty-urls

@octavsly
Copy link

octavsly commented Oct 16, 2020

Thank you.
Indeed. In my config.php I had only :
'overwrite.cli.url' => 'http://localhost',

I have changed it to

  'overwrite.cli.url' => 'https://nextcloud.server.bla',
  'htaccess.RewriteBase' => '/',

Then run occ maintenance:update:htaccess

@skjnldsv skjnldsv added 1. to develop Accepted and waiting to be taken care of and removed 0. to triage Pending approval or rejection. This issue is pending approval. labels Oct 16, 2020
@Luticus
Copy link

Luticus commented Oct 21, 2020

For anyone else doing this in the future @octavsly has the right idea, just don't forget to run this command once you update your config.php:

sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess

until you do that, your change won't work. It's in the documentation that @skjnldsv posted.

@michaelof
Copy link
Author

Just for my understanding: Does this bug in fact making pretty-urls mandantory if you want to use contacts app?

@skjnldsv
Copy link
Member

Does this bug in fact making pretty-urls mandantory if you want to use contacts app?

Kind of :)
The generateUrl function we use for the contact isn't checking the index.php.
We'll fix nonetheless, this is why it's still opened. I'll see what I can do today ;)

@nextgen-networks
Copy link

nextgen-networks commented Nov 19, 2020

Short info/notice: problem still existed in 20.0.2 released today...

... until i edited my config like mentioned above and updated the (with occ maintenance:update:htaccess)

Thanks for the hint! Works like intended now :-)

@beccon4

This comment has been minimized.

@sse450
Copy link

sse450 commented Nov 23, 2020

I did the same modifications without any fix.

Using docker with nginx. Can we say that this htaccess method is also applicable to nginx. Editing apps/contacts/lib/Controller/ContactsController.php worked.

@skjnldsv
Copy link
Member

Editing apps/contacts/lib/Controller/ContactsController.php worked.

what did you do?

@sse450
Copy link

sse450 commented Nov 25, 2020

Applied octavsly's method:
apps/contacts/lib/Controller/ContactsController.php line 62 from $url = $this->urlGenerator->getAbsoluteURL('apps/contacts/' . $this->l10n->t('All contacts') . '/' . $contact); to $url = $this->urlGenerator->getAbsoluteURL('index.php/apps/contacts/' . $this->l10n->t('All contacts') . '/' . $contact);

Only the above worked for me.

@skjnldsv
Copy link
Member

I need to check if that is ok for people with nice urls, thanks for sharing

@FredericLespez
Copy link

FredericLespez commented Nov 30, 2020

For me, even with pretty urls enabled, I am still seeing this bug. It displayed an error message 'Contact not found' when clicking on a contact in the search results.
Server : Debian Buster, Apache 2.4.38, PHP 7.3.19, PostgreSQL 11.9, Nextcloud 20.0.2, Contacts 3.4.2

Patching 'apps/contacts/lib/Controller/ContactsController.php' didn't solve the problem but the error message 'Contact not found' was no longer displayed.

@skjnldsv
Copy link
Member

COuld be an url encode problem. There is another deeper issue that exists since a few version.
If the addressbook contains special characters such as spaces or accents, it double encode it on contacts and is breaking the app

@tdoerschel
Copy link

Yes, it is broken when pretty url is not enabled (aka showing index.php) :)

It seems to be related to the php function used to generate the route https://github.com/nextcloud/server/blob/2a054e6c04e0a40421510eb889cbf59f153c5177/apps/dav/lib/Search/ContactsSearchProvider.php#L184-L188

I had the same issue on my 2 instances after upgrading to NC20.
Enabling pretty url as described worked.

@bernd-wechner
Copy link

Enabling pretty url as described worked.

That's to be expected, given the URL that I see in the address bar dafter clicking a contact search result. BUT alas the docs on supporting Pretty URls are sadly shallow.

Shallow in that they provide a occ command that does nothing on my system (and hence I'd love to find out where the source code for a given occ command resides so I can diagnose), but that aside all I can hope the occ command does for me is append to the sites root directory .htaccess file, an Apache syntax set of instructions for redirects.

Which is a good start, but it would be so so much nicer for those of us who don't use Apache (and that is no small group of people in 2002 given nginx and lightpd kick Apache's ass performance and resource wise) if the docs provided a lucid plain English summary of the URLs that need to be rewritten (as it's fairly easy with any webserver to insert index.php into URLs that lack it, but done universally is going to break all the URLs that Nextcloud uses that don't have index.php in them and so what's needs is a list of used NextCloud paths known to be served by index.php and a list that it uses that are known not to be - remote.php and static files spring immediately to mind).

So I can not right now even see the Apache instructions let alone begin to decrypt their intent for re-implementation in nginx or lighttpd. All of which is a heck of a rigmarole just because the Contacts app does not abide by Nextcloud norms and generates invalid URLs. To be honest, I could probably write one line config to accept contacts app URLs that are broken and rewrite them ...

@FredericLespez
Copy link

As I said in my previous comment, the workarounds didn't work for me.

Here is what happens in the Firefox console when I try to access a contact with the URL generated by the unified search.

URL generated by the unified search : https://<server>/apps/contacts/direct/c3b6f39e-0b43-4530-8f58-c4df0c013faa~Contacts%20Communs_shared_by_64dfd8f0-9a52-1037-890c-0d92e032c29f

Firefox console output (edited):

https://<server>/apps/contacts/Tous%20les%20contacts/c3b6f39e-0b43-4530-8f58-c4df0c013faa~Contacts%20Communs_shared_by_64dfd8f0-9a52-1037-890c-0d92e032c29f
https://<server>/ocs/v2.php/search/providers?from=%2Fapps%2Fcontacts%2FTous%2520les%2520contacts%2Fc3b6f39e-0b43-4530-8f58-c4df0c013faa~Contacts%2520Communs_shared_by_64dfd8f0-9a52-1037-890c-0d92e032c29f
https://<server>/remote.php/dav/addressbooks/users/64e0585c-9a52-1037-890d-0d92e032c29f/Contacts%20Communs_shared_by_64dfd8f0-9a52-1037-890c-0d92e032c29f/c271e6a9-bd9b-4de4-a55d-84bd247264c0.vcf

As you can see in the last URL, suddenly Contacts Apps try to access a contact whose id is c271e6a9-bd9b-4de4-a55d-84bd247264c0 (instead of c3b6f39e-0b43-4530-8f58-c4df0c013faa). And it failed (Contact not found).

Hope it helps.

@skjnldsv
Copy link
Member

@FredericLespez what is the name of the addressbook of this contact?
You have a very different issue

@FredericLespez
Copy link

@skjnldsv The name of the address book is "Contacts Communs".

@FredericLespez
Copy link

@skjnldsv Even with index.php, it doesn't work ("Contact not found").

@osm-frasch
Copy link

From my side exactly the same
When I click on a contact via the global search, I get a white page.

Nextcloud-Version 20.0.3
Contacts 3.4.2
PHP: 7.3.16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of bug Something isn't working high High priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.