Ticket #199 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

PHP wrapper object code

Reported by: Shnapoo Owned by: moo
Priority: major Milestone: 1.3.0
Component: website Version: 1.2.1
Keywords: Cc:
Blocked By: PHP Version:
Application: Need User Feedback: no
Other Exts: SAPI: Irrelevant
Probability: 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

Changed 3 years ago by moo

  • status changed from new to closed
  • resolution set to fixed

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.