Bug 314911

Summary: Opening declaration place from function information opens file from different project
Product: [Applications] kdevelop Reporter: Jakub Caban <kuba>
Component: Language Support: PHPAssignee: kdevelop-bugs-null
Status: REPORTED ---    
Severity: normal CC: cyberbeat, mail, opi
Priority: NOR    
Version First Reported In: git master   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Patch trying to address this issue.

Description Jakub Caban 2013-02-11 15:30:24 UTC
It happens only in git (all component built from git).

Many times when I hover over function (class, defined constant etc.) and press the "decl: file.php:line" anchor I end up with opened similar file, but from different project.

I have projects folder with numerous projects, most of which use similar framework, therefore have same directory structure and PHP classes and functions declared.

It's really hard to create 100% reproducible test case - it happens a lot, but seems randomly to me.

I have no idea what additional information may be helpful, so feel free to ask.

Reproducible: Always
Comment 1 Jakub Caban 2013-03-06 10:45:37 UTC
It happens right now 100% times. It usually opens file from project on which I was previously working. But on clean instance of KDevelop it opens file from what looks like randomly chosen project from project folder.
Comment 2 Carlos Vives 2013-09-28 10:44:23 UTC
I can confirm this happening to me with KDevelop 4.5.1 and PHP 1.5.1 from stable sources as well, haven't tried git.

Very troubling if you're using in-house frameworks or similarly named classes between projects, because code it also affects code completion and, if you're not vigilant, you may change files from unrelated projects.

I wouldn't be surprises if bug 213747 is related to this.
Comment 3 Milian Wolff 2013-09-28 16:33:08 UTC
Created attachment 82526 [details]
Patch trying to address this issue.

Can someone of you try to apply the attached patch to kdev-php and see whether it helps with the problem?

It now prefers "nearby" declarations, meaning declarations where the path difference between $targetFile/.. and $potentialMatchFile/.. is shortest.

The project itself cannot be used here due to thread safety issues. The above should be nicer anyways I hope but of course can be just as wrong in some circumstances I'm afraid :(
Comment 4 Jakub Caban 2013-09-29 11:39:18 UTC
I've just applied it and to try opened file at:

~/projects/project1/index.php
than through declaration of class "Module" it got me to:
~/projects/project2/classes/module.php

So no difference. Although maybe I should clear some kdev cache? If so, please tell me how :)
Comment 5 Milian Wolff 2013-09-30 22:22:30 UTC
Yep, just remove ~/cache/.kdevduchain or try the "reparse" button in the problem's toolview, just set the scope to all projects.
Comment 6 Jakub Caban 2013-10-01 08:25:47 UTC
OK - I did both, but unfortunately no go :(

Situation:

I opened Kdevelop after clearing cache and reparsed with scope "all projects". Project "project1" was opened, so as previously in:
~/projects/project1/index.php
I've opened Module class declaration. It went well:
~/project/project1/classes/module.php

But that I've closed project1 and opened project2 (in the same Kdevelop session) and in file:
~/projects/project2/index.php
I tried again to open declaration of class Module. Ant it went to:
~/projects/project1/classes/module.php

And so on - opening any declaration in project2 opens it from project1. I believe it may be somehow related to sessions handling in Kdevelop...?
Comment 7 Milian Wolff 2013-10-03 09:05:42 UTC
Hm are there openly accessible project which one may use to reproduce this issue and try to fix it?
Comment 8 Jakub Caban 2013-10-10 15:52:39 UTC
I've tried to create some lightweight test project, but anytime I try to create a few files one it simply works... Than when I switch to my framework it's no working once again :(

Unfortunately I am not allowed to openly publish all framework, although I could send it privately to you for testing purposes, if that could help.
Comment 9 Alexander Opitz 2014-12-05 09:02:00 UTC
Duplicate of Bug #284931 ?
Comment 10 Kevin Funk 2014-12-05 11:10:51 UTC
*** Bug 284931 has been marked as a duplicate of this bug. ***
Comment 11 Justin Zobel 2021-03-09 22:47:41 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.