The first line of code reads
Code: Select all
if(!isset($GLOBALS[CMS_VERSION])) die('Attempt to use ADODB from outside of CMS');
Code: Select all
if(!isset($GLOBALS['CMS_VERSION'])) die('Attempt to use ADODB from outside of CMS');
Code: Select all
if(!isset($GLOBALS[CMS_VERSION])) die('Attempt to use ADODB from outside of CMS');
Code: Select all
if(!isset($GLOBALS['CMS_VERSION'])) die('Attempt to use ADODB from outside of CMS');
As also noted in Re: Warning in CMS 1.1.3.1, TinyMCE, this code should be:mesaverde wrote:Code: Select all
if(!isset($GLOBALS['CMS_VERSION'])) die('Attempt to use ADODB from outside of CMS');
Code: Select all
if(!array_key_exists('CMS_VERSION', $GLOBALS)) die('Attempt to use ADODB from outside of CMS');
Code: Select all
if(!in_array('CMS_VERSION', array_keys($GLOBALS)) die('Attempt to use ADODB from outside of CMS');
In fact, I agree with your performance concerns. The third option is certainly the slowest for the reasons you state; however, the second option could be as efficient as "isset" or as inefficient as the combination of "array_keys" and "in_array" depending on the implementation. However, these are the options for testing for the existence of an element in a PHP array (or object). The third option is required for PHP 4.0.5 and earlier and the second option is supported in PHP 4.0.7 and later. (In PHP 4.0.6, the "array_key_exisits" function was named "key_exists".)Bobonov wrote: even if all the 3 solution works, only one is the best in performance terms.
The problem is that "isset" is the logical negation of "is_null" (possibly applied to multiple arguments). In fact, the original poster could have changed the line in question to:Sy wrote: This isn't an error as such, but it will cause a warning to be displayed if you have errors set at the appropriate level in PHP.
Line 104. of TinyMCE.module.php, reads:
if (!$this->wysiwygactive ) {if (!$this->wysiwygactive && isset($_SESSION["tiny_live_textareas"]) ) {
Change this to:
if (!$this->wysiwygactive && isset($_SESSION["tiny_live_textareas"]) ) {
I get the warning:
Notice: Undefined index: tiny_live_textareas in C:\eska\modules\TinyMCE\TinyMCE.module.php on line 104
I always have error reporting set to display absolutely everything, which is good practice for development.
Code: Select all
if(is_null($GLOBALS['CMS_VERSION'])) die('Attempt to use ADODB from outside of CMS');
Code: Select all
<__html>
<head>
<title>isset and is_null test</title>
</head>
</__body>
<p>
isset( $variable ): <?php var_dump( isset( $variable ) ); ?><br />
is_null( $variable ): <?php var_dump( is_null( $variable ) ); ?><br />
</p>
<p>
$variable = NULL;<?php $variable = NULL; ?><br /><br />
isset( $variable ): <?php var_dump( isset( $variable ) ); ?><br />
is_null( $variable ): <?php var_dump( is_null( $variable ) ); ?><br />
</p>
<p>
$variable = 1;<?php $variable = 1; ?><br /><br />
isset( $variable ): <?php var_dump( isset( $variable ) ); ?><br />
is_null( $variable ): <?php var_dump( is_null( $variable ) ); ?><br />
</p>
<p>
unset( $variable );<?php unset( $variable ); ?><br /><br />
isset( $variable ): <?php var_dump( isset( $variable ) ); ?><br />
is_null( $variable ): <?php var_dump( is_null( $variable ) ); ?><br />
</p>
<p>
isset( $arr ): <?php var_dump( isset( $arr ) ); ?><br />
is_null( $arr ): <?php var_dump( is_null( $arr ) ); ?><br />
</p>
<p>
$arr = array();<?php $arr = array(); ?><br /><br />
isset( $arr ): <?php var_dump( isset( $arr ) ); ?><br />
is_null( $arr ): <?php var_dump( is_null( $arr ) ); ?><br />
</p>
<p>
isset( $arr['foo'] ): <?php var_dump( isset( $arr['foo'] ) ); ?><br />
is_null( $arr['foo'] ): <?php var_dump( is_null( $arr['foo'] ) ); ?><br />
</p>
<p>
$arr['foo'];<?php $arr['foo']; ?><br /><br />
isset( $arr['foo'] ): <?php var_dump( isset( $arr['foo'] ) ); ?><br />
is_null( $arr['foo'] ): <?php var_dump( is_null( $arr['foo'] ) ); ?><br />
</p>
<p>
$arr['foo'] = NULL;<?php $arr['foo'] = NULL; ?><br /><br />
isset( $arr['foo'] ): <?php var_dump( isset( $arr['foo'] ) ); ?><br />
is_null( $arr['foo'] ): <?php var_dump( is_null( $arr['foo'] ) ); ?><br />
</p>
<p>
$arr['foo'] = 1;<?php $arr['foo'] = 1; ?><br /><br />
isset( $arr['foo'] ): <?php var_dump( isset( $arr['foo'] ) ); ?><br />
is_null( $arr['foo'] ): <?php var_dump( is_null( $arr['foo'] ) ); ?><br />
</p>
<p>
unset( $arr['foo'] );<?php unset( $arr['foo'] ); ?><br /><br />
isset( $arr['foo'] ): <?php var_dump( isset( $arr['foo'] ) ); ?><br />
is_null( $arr['foo'] ): <?php var_dump( is_null( $arr['foo'] ) ); ?><br />
</p>
<p>
unset( $arr );<?php unset( $arr ); ?><br /><br />
isset( $arr['foo'] ): <?php var_dump( isset( $arr['foo'] ) ); ?><br />
is_null( $arr['foo'] ): <?php var_dump( is_null( $arr['foo'] ) ); ?><br />
</p>
<p>
isset( $arr ): <?php var_dump( isset( $arr ) ); ?><br />
is_null( $arr ): <?php var_dump( is_null( $arr ) ); ?><br />
</p>
<__body>
</__html>