#27219 [NEW]: Compilation error in libmysql.c

From: Date: Wed, 11 Feb 2004 13:49:20 +0000
Subject: #27219 [NEW]: Compilation error in libmysql.c
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54751@lists.php.net to get a copy of this message
From:             martin at ibuildings dot nl
Operating system: Redhat 6.1
PHP version:      4.3.4
PHP Bug Type:     Scripting Engine problem
Bug description:  Compilation error in libmysql.c

Description:
------------
When a class does not have member variables, creating a static instance of
the class becomes impossible. See the code below. If the member variable
is declared, one onstance is created, and each next call to getInstance
will return the existing instance.Without the member var, new instances
are created every time.

Reproduce code:
---------------
class mySingleton
{
  // var $m_dummy = ""; // uncommenting this line is a 
                        // workaround

  function &getInstance()
  {
    static $s_instance = NULL;
    if ($s_instance == NULL)
    {
      echo "Creating a new instance<br>";
      $s_instance = new mySingleton();
    }
    else
    {
      echo "Using existing instance<br>";
    }
    return $s_instance;
  }
}

$tmp = &mySingleton::getIntance();
$tmp2 = &mySingleton::getIntance();



Expected result:
----------------
Creating a new instance
Using existing instance

Actual result:
--------------
Creating a new instance
Creating a new instance

-- 
Edit bug report at http://bugs.php.net/?id=27219&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27219&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27219&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27219&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27219&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27219&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27219&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27219&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27219&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27219&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27219&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27219&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27219&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27219&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27219&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27219&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27219&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27219&r=float


Thread (5 messages)

« previous php.bugs (#54751) next »