Mantis - Quercus
Viewing Issue Advanced Details
1963 minor always 08-22-07 14:43 09-04-07 11:09
rjc  
nam  
normal  
closed 3.1.2  
fixed  
none    
none 3.1.3  
0001963: return new self(...) fails

MediaWiki's ability to upload images and files is broken by this.

In includes/filerepo/LocalFile.php, there are lots of static methods with code like "return new self(...)" these return a parse error in Resin 3.1.2

Trying to change this to "return new LocalFile(..)" fails with stack overflow/infinte loop.

This appears to be a common PHP idiom for singletons/factories.

Notes
(0002227)
rjc   
08-23-07 12:26   
I temporarily fixed this by changing return new self(...) to return new (__CLASS__)(...) in all classes and subclasses in MediaWiki that used it, but I would appreciate fixing this, because I'd rather not patch the MediaWiki source to work with Quercus.
(0002236)
kim   
08-26-07 03:38   
Seems to be a parser issue: for 'new self' (no parentheses) it works fine. Changing c.q.p.QuercusParser, lines 3036-3039 (SVN HEAD) to:

        if (!name.equals("self") && token == '(')
          return parseFunction(className, name, isInstantiated);
        else
          return parseConstant(className, name);

works -- however seems more like a quick workaround.

+1 for fixing this as it is indeed a common (and perfectly legal) idiom, used e.g. by the Zend Framework frequently.
(0002257)
nam   
09-04-07 11:09   
php/093h