bugphpGroupWare - Bugs: bug #7370, Use of reserved php keyword in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #7370: Use of reserved php keyword in class.preferences.inc.php

Submitted by:  Kai Hofmann <powerstat>
Submitted on:  Wed 21 Jan 2004 09:30:11 PM UTC  
 
Item Group: 0.9.16RC2Category: API - Preferences
Severity: 6 - SecurityPriority: 9 - Immediate
Status: Wont FixPrivacy: Public
Assigned to: Dave Hall <skwashd>Open/Closed: Closed
Component Version: SVNOperating System: None
Reproducibility: NonePlanned Release: None
Fixed Release: 

(Jump to the original submission Jump to the original submission)

Fri 23 Jan 2004 07:27:38 AM UTC, comment #6:

Sounds more like a problem with eclipse than phpGW.

I have a production install running fine - using the recommended php.ini setting, with error logging, it never complains about this.

This item is closed for 16.

Submit a patch or bug report for head and someone will eventually get around to looking at it.

I am not really interested in making a major change that affects most apps, just because an IDE is not happy. This is a minor problem for a few select few of people (read eclipse users). The whole thing still runs with it the way it is.

Cheers

Dave Hall <skwashd>
Project AdministratorIn charge of this item.
Fri 23 Jan 2004 06:22:51 AM UTC, comment #5:

To reproduce load the file in eclipse with installed xored php plugin (using php 4.3.4). Or try something like:
php -l -e -f file
(you need to set the correct path includes, because otherwise the parse will fail when includes/classes are required).

Exact error messages:

208: Expecting '}', found 'default'
208: Expecting '}', found: '$this'
208: Unexpected token: '->'
($this->forced = $this->default = $this->user = array();)
-----
225: Unexpected token: '->'
225: Unexpected token: 'default'
$this->default[$app] = $value;

236: Expecting 'EOF', found: 'default'
236: Expecting "as", found '->'
(foreach($this->default as ....)

Btw. for the case that you don't know how a scanner/parser combination works:
1) The scanner will analyse the input character stream and will tokenize it - i.e. generate one token for an identified keyword.

2) the parser will then use the tokens for checking the grammnar.

So the problem happens here in the scanner, because the scanner has no choice to decide if default in $this->default
is a variable or something other.
So usage of default is a bug here, because of reserved keyword failure.

Kai Hofmann <powerstat>
Thu 22 Jan 2004 02:51:19 PM UTC, comment #4:

my point is that is does NOT cause any errors. If you are getting an error I'd like to see the text of it and know how I can reproduce it.

php requires variables to be prepended with a $ for the sole purpose of distinguishing them from reserved words, constants, and function names. I do agree that using "default" as a constant or a function or class name will cause errors and should not be done.

From the URL, "You cannot use any of the following words as constants, class names, or function names. Using them as variable names is generally OK, but could lead to confusion."

I can see how using $for or $if could be confusing, but "default" has a very special case in php and so $default is not so confusing.

Bottom line, there is NO ERROR caused by this.

Chris Weiss <cw>
Project Administrator
Thu 22 Jan 2004 12:14:43 PM UTC, comment #3:

php 4.3.4

From above URL:

The following is a listing of predefined identifiers in PHP. None of the identifiers listed here should be used as identifiers in a your scripts. These lists include keywords and predefined variable, constant, and class names.

using $this->default etc. makes the error, because you will reference class constants etc. in the same way.
Identifier also means method names, variables etc. - it means all from the view of parser internals.
So NEVER use it!

Kai Hofmann <powerstat>
Wed 21 Jan 2004 10:33:34 PM UTC, comment #2:

I have tried 3 installs of phpgw, using the recommended php.ini config - no problems, closing.

Dave Hall <skwashd>
Project AdministratorIn charge of this item.
Wed 21 Jan 2004 10:28:23 PM UTC, comment #1:

which means that you can't use "default" as a constant, which isn't one. I've never seen a parse error on that class.

What php version are you using?

Chris Weiss <cw>
Project Administrator
Wed 21 Jan 2004 09:30:11 PM UTC, original submission:

"default" is wrongly used as a member variable - this results in parsing errors because default is a reserved php keyword.
See: http://www.php.net/manual/en/reserved.php

Kai Hofmann <powerstat>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 22 Jan 2004 12:15:28 PM UTCpowerstatStatusInvalid=>Wont Fix
Wed 21 Jan 2004 10:33:34 PM UTCskwashdCategoryAPI - phpGroupware API=>API - Preferences
  StatusNone=>Invalid
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1