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 136961 - Problems with PHP templates
Summary: Problems with PHP templates
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: CSL (API & infrastructure) (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Torbjorn Norbye
URL:
Keywords:
: 144386 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-06-11 00:24 UTC by Ayub Khan
Modified: 2009-02-19 20:45 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Error from DataObject.createFromTemplate() (2.19 KB, text/plain)
2008-06-11 00:25 UTC, Ayub Khan
Details
Error snapshot from IDE (203.30 KB, text/plain)
2008-06-18 19:45 UTC, Ayub Khan
Details
Php template that has the issue using DataObject.createTemplate() (2.92 KB, text/plain)
2008-06-18 19:47 UTC, Ayub Khan
Details
Error snapshot from IDE - uploaded again with correct mime (203.30 KB, image/png)
2008-06-18 19:49 UTC, Ayub Khan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ayub Khan 2008-06-11 00:24:51 UTC
I see 2 issues invoking templateDO.createFromTemplate(dataFolder, targetName);

1)
for templateDO a template defined in layer.xml, I get error (See attachement for stacktrace)

SEVERE [global]
java.lang.IllegalArgumentException: unmatched braces in the pattern at position 19
	at org.openide.util.MapFormat.processPattern(MapFormat.java:213)


with content as follows

============
<?php

    //namespace org::netbeans::saas;

    class SaasService {
    
        public function SaasService() {
            $this->__construct();
        }

        public function __construct() {
        }
    
    }

?>
==============

2) for templateDO in the hg repository
"/main/websvc.saas.codegen/src/org/netbeans/modules/websvc/saas/codegen/php/resources/RestConnection.template", I get
following truncated contents instead of the full

===================
<?php
    
    require_once "HTTP/Request.php";
    require "RestResponse.php";

    class RestConnection {

        private $url = "";
        private $response = "";
        private $responseBody = "";
        private $req = null;

        public function RestConnection($url = "", $params = null) {
======================
Comment 1 Ayub Khan 2008-06-11 00:25:35 UTC
Created attachment 62640 [details]
Error from DataObject.createFromTemplate()
Comment 2 Tomasz Slota 2008-06-11 09:09:15 UTC
The web services templates are not maintained by the PHP team
Comment 3 Ayub Khan 2008-06-12 19:49:26 UTC
The main issue here is in using template files with contents that has "__" (described as 1st issue). This causes the
second issue with truncated contents.

I think this is a bug in the org.openide.util.MapFormat.processPattern() method, so assigning this to the nb utilities
component.
Comment 4 Marian Petras 2008-06-13 12:26:44 UTC
Reassigned to component "openide". I do not know which subcomponent to use.
Comment 5 Jiri Skrivanek 2008-06-16 16:01:03 UTC
I tried DataObject.createFromTemplate() with mentioned templates and new files were created successfully. Please,
provide a test case or steps how to reproduce in IDE.
Comment 6 Jiri Skrivanek 2008-06-17 07:55:55 UTC
No feedback from the reporter. Closing as worksforme.
Comment 7 Ayub Khan 2008-06-18 19:45:11 UTC
Created attachment 63032 [details]
Error snapshot  from IDE
Comment 8 Ayub Khan 2008-06-18 19:47:17 UTC
Created attachment 63033 [details]
Php template that has the issue using DataObject.createTemplate()
Comment 9 Ayub Khan 2008-06-18 19:49:32 UTC
Created attachment 63034 [details]
Error snapshot  from IDE - uploaded again with correct mime
Comment 10 Ayub Khan 2008-06-18 19:50:00 UTC
Sorry for responding late!

I had removed the offending code in the template file on the NB repository. I am attaching the template file that causes
the issue. Also I am lowering the priority of this bug to P2, since I can live without the __construct() function for now.
Comment 11 Jiri Skrivanek 2008-06-19 09:37:15 UTC
It is still incomplete. The attached screen shot just shows the exception and DataObject.createTemplate() works for me
with attached template. Please, steps to reproduce or test case.
Comment 12 Lukas Jungmann 2008-06-19 19:14:21 UTC
I shown steps to reproduce this to Jirka earlier today, so removing the INCOMPLETE keyword...
Comment 13 Antonin Nebuzelsky 2008-07-01 11:07:57 UTC
Any reason some templates really need to use __?

Comment 14 Jiri Skrivanek 2008-07-01 12:19:16 UTC
__ is a terminator set in GsfDataLoader (see f.setLeftBrace( "__" )). That's why it cannot be used in template.
Comment 15 Ayub Khan 2008-07-18 01:11:43 UTC
I am lowering the priority of this issue to P4, since we are not using literals prefixed with "__" in any of our PHP
templates.
Comment 16 Antonin Nebuzelsky 2008-07-18 12:48:58 UTC
Rather a wontfix I think.
Comment 17 Lukas Hasik 2008-08-20 10:05:26 UTC
*** Issue 144386 has been marked as a duplicate of this issue. ***
Comment 18 scolytus 2008-08-20 10:25:59 UTC
first of all, I apologize for the duplicated issue, haven't really searched.

If I understand what you're saying, you won't fix that?
If so, I can't agree. If you want to support PHP, users should be able to create templates containing a PHP 5 style
constructor! In fact, every magic PHP function starts with a '__', that's part of the game. 
Comment 19 Exceptions Reporter 2008-08-21 18:03:45 UTC
This issue has already 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=6567
Comment 20 Petr Pisl 2008-08-26 10:53:07 UTC
This issue should be fixed. Also I think P4 is not the right priority. It's at least P3. The problem is that PHP users
are not able to use the functionality to create template from their files, if the file contains magic functions, which
are very common. 

Steps to reproduce (You have to have a distribution with PHP cluster):

1) Create new php file and replace the content with:
<?php
class test {
    function __construct() {
    }
    function __destruct() {
    }
}
?>

2) Invoke Save as Template... action from the context menu and save it as a template.
3) Try to create new file from this template -> you get the exception

I'm reassigning the issue to Radek, for more evaluation. 

Comment 21 rmatous 2008-08-26 12:43:46 UTC
According to jskrivanek comments the cause is GsfDataLoader:181 (f.setLeftBrace) where as braces is "__". We would like
to see this issue fixed because php templates containing constructor (in php __construct()).

Seems to me that we cannot fix this problem in php. But we would like to see this issue fixed because its very typical
php scenario, so priority increased. Please, evaluate, thanks.
Comment 22 Torbjorn Norbye 2008-08-26 23:43:26 UTC
Setting the left brace to "__" is normal - it's what is shown in the javadoc example for MapFormat - and it's also what
the Java module sets it to.

However, in looking at the Java module I noticed they had another call in there:
                f.setExactMatch(false);
This apparently turns off error checking on __ in the file - which is exactly what I want. When I did that, I can
successfully create PHP files containing __ as well.

Fixed in c6618a7ab4d5.

Comment 23 Petr Pisl 2008-08-27 10:44:06 UTC
Thanks, Tor, now it's really work. 
Comment 24 Exceptions Reporter 2008-09-10 15:35:28 UTC
This issue has already 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=6567
Comment 25 Martin Krauskopf 2009-02-02 14:36:52 UTC
'ruby/gsf -> editor/csl' mass-move to be able to deleted gsf/ruby. Having to
change the version and platform of all closed moved issues to the same due to
Issuezilla deficiencies - choosing version == 6.5 and TM = 7.0.