<br><br><div class="gmail_quote">On Sat, Jul 3, 2010 at 6:52 PM, Sayontan Sinha <span dir="ltr">&lt;<a href="mailto:sayontan@gmail.com">sayontan@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Simon,<br>This is exactly what I am trying to explain to you - the big picture.<br><br>Take the options loop for example:<div class="im"><br>
foreach ($options as $value) {<br>
        if (!isset($suffusion_options[$<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">value[&#39;id&#39;]])) {<br>
        $$value[&#39;id&#39;] = $value[&#39;std&#39;];<br>
    }<br>
    else {<br>
                $$value[&#39;id&#39;] = $suffusion_options[$value[&#39;id&#39;]];<br>
    }<br>
}<br>
<br>
</blockquote><br></div>$options is a very big array that comes from theme-options.php, where <b>each</b> of the 400 odd elements with an id has an &quot;std&quot; value. The entire options framework is predicated upon this foundation (for the last 10 months). You will never get the so-called error. Having your extra condition will cause it no difference - your example is more lines of code that will give you no advantage. You approach this from the angle that if $value[&#39;std&#39;] is not set (which will never happen in that array), $$value[&#39;id&#39;] will not get set, while the code in theme-options.php ensures that $value[&#39;std&#39;] will be present for anything with an id. If it isn&#39;t, my theme will have bigger problems to handle than a debug message. <br>

<br>You are trying to split hairs between isset and is_null. I am simply making use of the fact that if something is not set, its value is still null (though that will give you a notice, but only if you have debug turned on - never otherwise). It doesn&#39;t damage the code in any way and it surely doesn&#39;t affect how the theme runs. All these arrays that you are asking me to write conditions around, these are arrays that I control, not something that a user defines. Hence I know what is in them - checks such as this will only increase cycle times in so many cases without adding value. The next thing you know, you will ask me to check for isset around different global variables, because all my global variables are initiated through the above code and if I have an &quot;isset&quot; around $$value[&#39;id&#39;], there is a high likelihood that a global variable will not be initialized according to you - a condition, which according to me will never occur in the theme.<br>
</blockquote><div><br>I get what you&#39;re trying to do. But checking for the existence of an array element does not take up that much additional time. Stop and consider what happens when the array element doesn&#39;t exist. PHP raises an error condition. It then writes something to the Apache log files (this happens whether or not WordPress has WP_DEBUG turned on) and then attempts to recover. The recovery mechanism is to evaluate the value as NULL. So yes, it has the desired effect within your code, but the amount of overhead to get there (raising error condition and especially writing to a log file) takes far more cycles than checking to see if the array element exists beforehand. And then once you&#39;ve determined whether or not the array element exists, you&#39;re copying it. This takes up more time and a lot more memory (as opposed to using a reference). If you&#39;re really concerned about performance, try both methods and benchmark them.<br>
<br>The other problem with the errors is that it&#39;s filling up the Apache log files with a bunch of messages that don&#39;t serve any real purpose. Now if you need to look in the logs, there are thousands of error messages that you need to wade through that are just a distraction, making it very difficult to find anything else that might be important. It&#39;s just good manners to make your code as &quot;quiet&quot; as possible in the log files since you never know what else is going on with the machine.<br>
<br>As far as the globals go, if there is a problem checking any unassigned global values, that would also show up in the log file. If there are no such messages in the logs, then the condition you&#39;re mentioning doesn&#39;t exists and therefore doesn&#39;t need to be addressed: the globals are being initialized before any reference to them, which is all that you need be concerned about.<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I don&#39;t know how else to explain this - it is such a simple concept that should raise no eyebrows, yet you seem to be bent upon trying to find flaws in it.<br></blockquote><div><br>No one is trying to find flaws in your system. But errors are being written to log files, which means that something potentially bad is happening. It doesn&#39;t take much to change your code to remove the errors. No one is telling you that your system needs to be changed, only that it should be enhanced.  If all theme and plugin authors make their code as robust and error free as possible, then WordPress itself will perform better -- which is what we all want.<br>
 <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><font color="#888888"><br>Sayontan.</font><div><div></div><div class="h5"><br><br>
<div class="gmail_quote">On Sat, Jul 3, 2010 at 6:12 PM, Simon Prosser <span dir="ltr">&lt;<a href="mailto:pross@pross.org.uk" target="_blank">pross@pross.org.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>On 04/07/2010 01:09, Sayontan Sinha wrote:<br>
&gt; Pick the very first one for example, which says that there is no index<br>
&gt; called &quot;#horizontal-outer-widgets-1 a:hover/color&quot; in<br>
&gt; theme-definitions.php. That is incorrect information and you really need<br>
&gt; to see the code to see how it works. This particular index has been<br>
&gt; defined multiple times, and there is an inheritance array defined, so if<br>
&gt; the variable is not defined in one place it picks it from the parent etc.<br>
</div>first few examples:<br>
if ($style_settings[$mapped_style] != null) {<br>
$style_settings[$mapped_style] is not defined so you get the Notice.<br>
<br>
if ( isset($style_settings[$mapped_style]) ) {<br>
does the same thing with no errors.<br>
<br>
<br>
else {<br>
        $parent = $style_settings[&quot;parent&quot;];<br>
$style_settings[&quot;parent&quot;] is empty and causing the Notice, so again we<br>
check:<br>
<br>
<br>
else {<br>
<br>
        if ( isset( $style_settings[&quot;parent&quot;] ) ) { $parent =<br>
$style_settings[&quot;parent&quot;]; }<br>
<br>
Most of the admin section errors come from this section:<br>
<br>
foreach ($options as $value) {<br>
        if (!isset($suffusion_options[$value[&#39;id&#39;]])) {<br>
        $$value[&#39;id&#39;] = $value[&#39;std&#39;];<br>
    }<br>
    else {<br>
                $$value[&#39;id&#39;] = $suffusion_options[$value[&#39;id&#39;]];<br>
    }<br>
}<br>
<br>
which can be written as:<br>
<br>
foreach ($options as $value) {<br>
if ( isset( $value[&#39;id&#39;] ) ) {<br>
        if (!isset($suffusion_options[$value[&#39;id&#39;]])) {<br>
        if ( isset( $value[&#39;std&#39;] ) ) {<br>
        $$value[&#39;id&#39;] = $value[&#39;std&#39;];<br>
        }<br>
    }<br>
    else {<br>
                $$value[&#39;id&#39;] = $suffusion_options[$value[&#39;id&#39;]];<br>
    }<br>
        }<br>
}<br>
<br>
The snippet above is used in numerous files to get the theme options and<br>
is responsible for 99% of the notices displayed.<br>
<font color="#888888"><br>
--<br>
MyBlog : <a href="http://www.pross.org.uk/" target="_blank">http://www.pross.org.uk/</a><br>
</font><div><div></div><div>Plugins : <a href="http://www.pross.org.uk/plugins/" target="_blank">http://www.pross.org.uk/plugins/</a><br>
Themes: <a href="http://wordpress.org/extend/themes/profile/pross" target="_blank">http://wordpress.org/extend/themes/profile/pross</a><br></div></div></blockquote></div></div></div></blockquote></div>