Opened 6 years ago

Closed 6 years ago

#199 closed defect (fixed)

PHP wrapper object code

Reported by: Shnapoo Owned by: moo
Priority: major Milestone: 1.3.0
Component: website Version: 1.2.1
Keywords: Cc:
Application: PHP Version:
Other Exts: SAPI: Irrelevant
Probability: Blocked By:
Blocking:

Description

Hi there,

I was unable to log into the website (although giving right password for sure). Just wanted to inform you of a tiny bug in the XCache wrapper object code provided here.

It currently doesn't handle its singleton correctly. When calling xcache::getInstance() you get a new instance each time, because the class doesn't store the reached out instance.

Bad version:

public static function getInstance() 
{
    return (self::$xcobj instanceof XCache) ? self::$xcobj : new XCache; 
}

Fixed version should look like:

public static function getInstance() 
{
    if( !(self::$xcobj instanceof XCache) ){
        self::$xcobj = new XCache;
    }
    return self::$xcobj; 
}

Change History (1)

comment:1 Changed 6 years ago by moo

  • Resolution set to fixed
  • Status changed from new to closed

thx, fixed in XcacheApi, it was a user contributed example

btw, i won't have to search it if you told me the url or wiki name :)

Note: See TracTickets for help on using tickets.