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 157421 - Fast import should use "dirname(__FILE__)" or "./filename.php"-syntax
Summary: Fast import should use "dirname(__FILE__)" or "./filename.php"-syntax
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.2
Hardware: All All
: P4 blocker with 1 vote (vote)
Assignee: Ondrej Brejla
URL: http://www.php.net/manual/en/function...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-26 08:43 UTC by jlem
Modified: 2012-11-06 03:12 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed patch (1.82 KB, patch)
2012-11-03 15:10 UTC, Ondrej Brejla
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jlem 2009-01-26 08:43:14 UTC
Fast import should start file paths with dirname(__FILE__) or at least it should be available as an option.
When current file is included/required from other file, the "../..." syntax doesn't work.
Comment 1 Tomasz Slota 2010-02-10 08:45:56 UTC
reassigning to default owner
Comment 2 Filip Zamboj 2010-09-15 12:28:15 UTC
batch reassigning
Comment 3 _ wadechandler 2012-11-01 15:44:21 UTC
This is technically a bug. If just the file name is used, then it must be included on the include_path. This doesn't work if your included file is in a subdirectory of your project which isn't actually part of the include_path. So, if relative to some file up the stack, then ../../somefile.php works fine. If in the same directory, then ./somefile.php should be used. Also, it would be handy if one has patterns they require to be able to pick dirname(__FILE__)/somefile.php as an option. The issues with . and .. and full paths and relative paths with no periods is detailed well at:
http://www.php.net/manual/en/function.include.php
Comment 4 _ wadechandler 2012-11-01 15:48:00 UTC
I am going ahead and changing the version to 7.2. This needs to remain current on the list of issues.
Comment 5 _ wadechandler 2012-11-01 15:50:57 UTC
Updating the summary to reflect the "./filename.php" portion of the problem. This isn't simply related to dirname(__FILE__) as the issue is that NetBeans doesn't correctly follow the documentation of include per the link I have already provided.
Comment 6 Ondrej Brejla 2012-11-01 15:56:11 UTC
It's P4 defect for me...fast import is not recommended action since we have autoloading in PHP 5. But when I'll have a time, I'll look at it. Thanks for evaluation.
Comment 7 _ wadechandler 2012-11-02 22:31:03 UTC
Your welcome on the evaluation. Is there something which tells the user that fast import perhaps isn't the desired action? To me if it is a feature of the IDE it should not create incorrect code which is the case if one can not adjust include_path which is the case, and in many cases would not be wanted. Probably that would be nearly all cases for sub-directories of files to be included in the users project.I will investigate further from a usability etc point of view. Thank you.
Comment 8 Ondrej Brejla 2012-11-03 09:29:28 UTC
(In reply to comment #7)
> To me if it is a feature of the
> IDE it should not create incorrect code

Definitely yes ;) That's why it's a valid defect. But with a low priority for me now...I have more crucial bugs to fix now. But as I wrote, I'll try to look at it...I put it into my todo list. Thanks.
Comment 9 _ wadechandler 2012-11-03 13:53:21 UTC
Thanks much. I noticed something else now.

With the latest updates on my install on Linux I'm seeing that fast import does nothing. However, I can type 

include("|"); 

and at the cursor CTRL+SPACE and the files to import show up, and if I have the structure:

php-test-project
-index.php
-inc
--1.php
--2.php

and I am in 2.php, then I see 1.php. If I select it, then I get:
include("1.php");

which I would really want
include("./1.php");
Comment 10 Ondrej Brejla 2012-11-03 14:04:53 UTC
...and...what? I don' t know what's the issue. If you want a a path prefix, just write it there.  Or you want some option with a checkbox, which tells NetBeans that your included completed files should use "./" path prefix? Then file a new enhancement.
Comment 11 _ wadechandler 2012-11-03 14:13:19 UTC
To first understand the problem, you need to read the link I have provided in the issue. Not having the ./ in front of the file name makes the import be treated significantly different. This is having inc on the include_path versus not. Since it isn't, then it should most definitely be prefixed with a ./ since it is in the same folder. The IDE is creating incorrect code in the case I'm providing as in no case would one want the folder inc in their project on the global include_path variable. The point of using an IDE is to make work better and faster not to just have a text editor. There lies the issue.
Comment 12 _ wadechandler 2012-11-03 14:15:50 UTC
Perhaps the fix is to provide two options for what to place into the file when one clicks on the auto complete item. Could be 1.php and ./1.php. That would give a person an option perhaps. One could view it as simply an enhancement, but that doesn't do justice to the documentation of PHP compared to the editing feature set. Too, in the context of which one is editing, the IDE knows the file is relative. If the intent is to treat it as relative, then it is an outright bug as that is not what will happen. If the intent is to simply show the names, albeit showing them relative, and then to just get the name there as fast as possibly, then that is something else entirely.
Comment 13 Ondrej Brejla 2012-11-03 14:39:26 UTC
Ok, I'll try to look at it as well.
Comment 14 Ondrej Brejla 2012-11-03 15:10:17 UTC
Created attachment 127060 [details]
Proposed patch

This patch should fix it. I'll look at it once again probably on monday.
Comment 15 Ondrej Brejla 2012-11-05 09:05:59 UTC
Fixed in web-main #08417dc7d9be
Comment 16 Quality Engineering 2012-11-06 03:12:14 UTC
Integrated into 'main-golden', will be available in build *201211060001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/08417dc7d9be
User: Ondrej Brejla <obrejla@netbeans.org>
Log: #157421 - Fast import should use "dirname(__FILE__)" or "./filename.php"-syntax