This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 269680 - After attempting to rename a PHP class using Refactor, I get an error message and then Undo stops working
Summary: After attempting to rename a PHP class using Refactor, I get an error message...
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.2
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: issues@php
URL:
Keywords: RANDOM
Depends on:
Blocks:
 
Reported: 2017-01-30 06:15 UTC by aatelfer
Modified: 2017-06-21 12:37 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (101.17 KB, text/plain)
2017-01-30 06:15 UTC, aatelfer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description aatelfer 2017-01-30 06:15:47 UTC
Product Version = NetBeans IDE 8.2 (Build 201609300101)
Operating System = Linux version 3.16.0-4-amd64 running on amd64
Java; VM; Vendor = 1.8.0_111
Runtime = OpenJDK 64-Bit Server VM 25.111-b14

Reproducibility: Happens sometimes, but not always

STEPS:
  * In the PHP editor, put the mouse cursor on the Class name
  * Type "Ctrl+r"
  * Check "Rename Also File with the Declaration"
  * Click on button "Preview"
  * Click "Refactor"

ACTUAL:
  * The error happens randomly. Sometimes the file will be renamed, but the class name in the file is unchanged.
  * Undo stops working

EXPECTED:
  File ane class name should be updated.


Here is the exception from the IDE log:

WARNING [org.openide.util.WeakListenerImpl]: Can't remove java.beans.PropertyChangeListener using method org.netbeans.modules.csl.core.GsfDocument.removePropertyChangeListener from org.netbeans.modules.csl.core.GsfDocument@694d9a35, mimeType='text/x-php5', kitClass=null, length=6039, version=20, file=org.netbeans.modules.csl.core.GsfDataObject@3e74e4e7[/disk2/projects/gotham_casting/website/modules/migrate_gotham/src/Plugin/migrate/destination/GothamMemberImageRelationships.php@1ba0d673:3de1a974[invalid]]
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.netbeans.modules.refactoring.spi.impl.RefactoringPanel$2
msg
Caused: org.openide.filesystems.FileStateInvalidException: /disk2/projects/gotham_casting/website/modules/migrate_gotham/src/Plugin/migrate/destination/GothamMemberImageRelationships.php@1ba0d673:3de1a974[invalid]
	at org.openide.loaders.DataObject.find(DataObject.java:612)
Caused: org.openide.loaders.DataObjectNotFoundException: /disk2/projects/gotham_casting/website/modules/migrate_gotham/src/Plugin/migrate/destination/GothamMemberImageRelationships.php@1ba0d673:3de1a974[invalid]
	at org.openide.loaders.DataObject.find(DataObject.java:635)
	at org.netbeans.modules.csl.spi.support.ModificationResult.commit(ModificationResult.java:138)
	at org.netbeans.modules.csl.spi.support.ModificationResult.commit(ModificationResult.java:130)
	at org.netbeans.modules.refactoring.spi.RefactoringCommit.commit(RefactoringCommit.java:153)
Caused: java.lang.RuntimeException
	at org.netbeans.modules.refactoring.spi.RefactoringCommit.commit(RefactoringCommit.java:165)
	at org.netbeans.modules.refactoring.api.RefactoringSession.reallyDoRefactoring(RefactoringSession.java:166)
	at org.netbeans.modules.refactoring.api.RefactoringSession.access$100(RefactoringSession.java:79)
	at org.netbeans.modules.refactoring.api.RefactoringSession$1.run(RefactoringSession.java:122)
	at org.netbeans.modules.refactoring.api.RefactoringSession$1.run(RefactoringSession.java:120)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks.runWithOnSaveTasksDisabled(BeforeSaveTasks.java:93)
	at org.netbeans.editor.Utilities.runWithOnSaveTasksDisabled(Utilities.java:1617)
	at org.netbeans.modules.refactoring.api.RefactoringSession.doRefactoring(RefactoringSession.java:120)
	at org.netbeans.modules.refactoring.spi.impl.RefactoringPanel$2.run(RefactoringPanel.java:575)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
ALL [null]: The file /disk2/projects/gotham_casting/website/modules/migrate_gotham/src/Plugin/migrate/destination/GothamMemberImageRelationships.php seems no longer valid!
WARNING [org.netbeans.modules.versioning.util.Utils]: associateEncoding() no file object available for /tmp/vcs-1485739920737/vcs-1485753258816/GothamMemberImageRelationships.php
Comment 1 aatelfer 2017-01-30 06:15:51 UTC
Created attachment 163504 [details]
IDE log
Comment 2 Tomas Mysik 2017-03-28 06:33:57 UTC
The cause is:

 The file /disk2/projects/gotham_casting/website/modules/migrate_gotham/src/Plugin/migrate/destination/GothamMemberImageRelationships.php seems no longer valid!

BTW there are quite a lot of errors/warnings related to your project files in the attached log - is your project on a local or a network drive? Aren't your project files somehow corrupted? Would it help if you save all your project files before refactoring? Please give it a try and let us know, thanks.

@tzezula: Tome, please, don't you know whether PHP support should somehow filter invalid FileObjects or what to do with them? Or should this be done in the common refactoring part? Thanks a lot!

Not a P1 IMHO so lowering. Thanks for reporting.
Comment 3 aatelfer 2017-03-28 06:51:19 UTC
I don't think this has anything to do with whether or not I saved my files. I'm a programmer, I shouldn't have problems with my IDE refactoring my files. 

To answer your question, I don't have my files on a network drive. 

Btw, I think being unable to undo an action is a serious issue that needs to be handled as a priority 1 issue. 

Thank you.
Comment 4 Tomas Mysik 2017-03-28 07:16:51 UTC
(In reply to aatelfer from comment #3)
> I don't think this has anything to do with whether or not I saved my files.

Why do you think so? Invalid FileObject likely means that the file was deleted. So, once more, could you please try to save all files before running refactoring? If it helps, it could help us to fix this issue.

> I'm a programmer, I shouldn't have problems with my IDE refactoring my
> files.

That is why you have reported this issue and we are now trying to solve it.

> To answer your question, I don't have my files on a network drive.

Thanks. In such a case, it is weird that there are quite many warnings about invalid FileObjects in your IDE log (maybe you are switching branches in your SCM?).

> Btw, I think being unable to undo an action is a serious issue that needs to
> be handled as a priority 1 issue.

It is not I am afraid. Looking at [1], this issue is not even a P2 IMHO.

Thanks.
[1] http://wiki.netbeans.org/BugPriorityGuidelines
Comment 5 aatelfer 2017-03-28 07:20:47 UTC
I'm done. Do you, bro. It's your reputation.
Comment 6 niabot 2017-06-08 13:45:58 UTC
I have the same issue. While refactoring a class name (including the renaming of the file) in php the refactoring stops with the same error message. 

The result is that the file is actually renamed, but all references to the class name will be left untouched. No text replacement is done anywhere, not in the moved file and also not in other files. (This usually breaks the code, because the class file will not be found)

Following this error all undo operations in Netbeans stop working until i restart the IDE.

PS: I have my files on a local share (assigned drive letter), but it also happened to me before on local files (Windows 7).
Comment 7 rahuijts 2017-06-21 12:37:37 UTC
Happens to me too, using a local disk only.

Another detail to help determine the severity of this bug: when this operation fails, it will also cause the editor tab that had the class file open, to be closed. The file is renamed but the class name is not. In my setup this does not result in any visible problem indication, but it does break my code. The first few times this happened to me, I did not notice the file was actually renamed, because the error message suggested there is no file under that new name and because the file browser will jump away from that file because the editor tab was closed.

I can understand that the editor tab is closed when the file is no longer deemed to be available (perhaps a small time-out would help?). It would be nice if the refactoring operation was atomic: if anything fails, the state should be as before the operation. But I have no idea how difficult that would be to implement.

Of course it would be even nicer if the operation did not fail. Please let me know how I can help fix it, because I use it a lot and it fails most of the time.