php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56866 apc_load_constants() weird behaviour in CLI
Submitted: 2006-02-28 14:07 UTC Modified: 2007-03-03 17:17 UTC
From: jasper at album dot co dot nz Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5.1.1 OS: Linux
Private report: No CVE-ID: None
 [2006-02-28 14:07 UTC] jasper at album dot co dot nz
Description:
------------
I am using apc_load_constants() and apc_define_constants() within CLI code. It appears that these functions behave differently in the CLI SAPI than they do in the Apache 2 SAPI, in that apc_load_constants() throws notices about constants already being defined. This does not occur in the Apache 2 SAPI.

Reproduce code:
---------------
<?php
if( ! apc_load_constants( 'general' ) ) {

	$constants = array(
		'HTTP_OK' =>		200,
		'HTTP_CREATED' =>	201,
		'HTTP_ACCEPTED' =>	202,
	);

	apc_define_constants( 'general', $constants );
	apc_load_constants( 'general' );

}
?>

Expected result:
----------------
The constants get defined and cached (this is what happens under Apache 2).

Actual result:
--------------
Notice: Constant HTTP_OK already defined in ...
Notice: Constant HTTP_CREATED already defined in ...
Notice: Constant HTTP_ACCEPTED already defined in ...

These errors refer to the second apc_load_constants() line, last function call in the snippet above.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-07 16:15 UTC] gopalv82 at yahoo dot com
Both apc_define_constants and apc_load_constants calls zend_register_constant.

The standard examples (in http://php.net/apc_define_constants ) seem to suggest that both can be called together, but in reality calling them both generates this valid warning.

Need to decide whether the documentation or code is to be fixed.
 [2007-03-02 21:20 UTC] sean at caedmon dot net
I fixed the docs to reflect this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 13:01:32 2024 UTC