Issues

ZF-11463: Undefined class constant | SaveHandler

Issue Type: Bug Created: 2011-06-09T22:14:20.000+0000 Last Updated: 2012-08-20T13:51:40.000+0000 Status: Open Fix version(s): Reporter: Andrew Wathasky (kangur91) Assignee: Ralph Schindler (ralph) Tags: - Zend_Session

  • DbTable
  • SaveHandler
  • zf-crteam-review

Related issues: - ZF-11823

Attachments:

Description

Error shows after Zend_Exception is thrown. Undefined class constant 'PRIMARY_TYPE_NUM' in /library/Zend/Session/SaveHandler/DbTable.php on line 522

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2011-06-13T14:36:07.000+0000

Could you provide some sample code showing how you're using Zend_Session_SaveHandler_DbTable, how you handle the exception, and some information on the exception that was thrown? (esp: the class name and stack trace)

Posted by Tibo Beijen (tbeijen) on 2011-06-27T09:31:28.000+0000

We're running into the same issue. It's just a fatal error, there's no exception. We're using Zend Framework 1.9.7

Error occurs on a PHP 5.3.3 server. Same code runs fine on a PHP 5.3.6 server

Error log:

<pre class="highlight">
[27-Jun-2011 11:15:25] PHP Fatal error:  Undefined class constant 'PRIMARY_TYPE_NUM' in /home/......../libraries/Zend/1.9.7/Zend/Session/SaveHandler/DbTable.php on line 522

Server having fatal error:

<pre class="highlight">
PHP 5.3.3 (cli) (built: Aug  7 2010 14:49:50)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Server running fine:

<pre class="highlight">
PHP 5.3.6 (cli) (built: Mar 19 2011 07:44:03)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with the ionCube PHP Loader v4.0.9, Copyright (c) 2002-2011, by ionCube Ltd., and
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Posted by Adam Lundrigan (adamlundrigan) on 2011-06-28T16:59:18.000+0000

@Tibo: Can you try it on PHP 5.3.3 with the latest ZF release? (or better yet, against SVN trunk)

I can't reproduce the issue against trunk on my dev machine:

<pre class="highlight">
PHP 5.3.3 (cli) (built: Jan 28 2011 14:53:13)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.5, Copyright (c) 2002-2011, by ionCube Ltd., and
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Posted by Nikolai Zujev (jaymecd) on 2011-07-08T12:14:23.000+0000

Hi,

I've discovered this issue few mins ago and found solution. checked with PHP 5.3.3 and ZF 1.11.7 & 1.11.8

How to reproduce: - use DbTable handler - trigger fatal error - see error message describer above

After debugging noticed that object is already destroyed and it does not have any static properties.

<pre class="highlight"> 
protected function _getPrimary($id, $type = null)
{
    $refl = new ReflectionClass($this);

    error_log('CHECK: '.print_r($refl->getConstants(),1));

    ... rest code ...
}



<pre class="literal">
[08-Jul-2011 11:38:31] PHP Fatal error:  xxx in /path/app/module/default/action/IndexController.php on line 26
[08-Jul-2011 11:38:31] PHP Stack trace: [clipped]
[08-Jul-2011 11:38:31] CHECK: Array()
[08-Jul-2011 11:38:31] PHP Fatal error:  Undefined class constant 'PRIMARY_TYPE_NUM' in /path/lib/Zend/Session/SaveHandler/DbTable.php on line 525
[08-Jul-2011 11:38:31] PHP Stack trace: [clipped]

Workaround is taken from php.net manual.

Pay attention to this note: {panel:title=http://php.net/manual/en/…} As of PHP 5.0.5 the write and close handlers are called after object destruction and therefore cannot use objects or throw exceptions. The object destructors can however use sessions. {panel}

By setting shutdown callback as: register_shutdown_function('session_write_close'); in the entry point (index.php) you avoid this issue.

Have a nice day, Nick

Posted by Nikolai Zujev (jaymecd) on 2011-07-08T20:38:40.000+0000

UPD. forgot to mention - front controller should be set to throw exceptions, aka in development mode.

Posted by elzo valugi (valugi) on 2012-02-27T09:53:25.000+0000

I get the same errror. This is quite strange as the user has SELECT rights.

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'green'@'localhost' for table 'application__users'' in /var/opt/ZendFramework/trunk/library/Zend/Db/Statement/Pdo.php:228

Stack trace: #0 /var/opt/ZendFramework/trunk/library/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) #1 /var/opt/ZendFramework/trunk/library/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array) #2 /var/opt/ZendFramework/trunk/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array) #3 /var/opt/ZendFramework/trunk/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE mydb...', Array) #4 /var/opt/ZendFramework/trunk/library/Zend/Db/Adapter/Pdo/Mysql.php(169): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBEmydb...') #5 /var/opt/ZendFramework/trunk/library/Zend/Db/Table/Abstract.php(835): Zend_Db_Adapter_Pdo_Mysql->describeTable('application__us...', 'mydb') #6 /var/opt/ZendFra in /var/opt/ZendFramework/trunk/library/Zend/Controller/Plugin/Broker.php on line 312 Fatal error: Undefined class constant 'PRIMARY_TYPE_NUM' in /var/opt/ZendFramework/trunk/library/Zend/Session/SaveHandler/DbTable.php on line 522

Posted by Juraj Seffer (jurajseffer) on 2012-08-20T13:51:40.000+0000

This exception seems to pop up only when another (fatal) error occurs before that.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts