Note that there are some explanatory texts on larger screens.

plurals
  1. POWordPress oddity with broken images (part 1)
    text
    copied!<p>Can you tell me your opinion of this, and possibly see if you can recreate it:</p> <p>Currently, the $post->post_content variable contains:</p> <pre><code>"before &lt;img src="/path/to/valid_img.gif" /&gt; after" </code></pre> <p>This code placed at the top of the theme header.php...</p> <pre><code>------ Code -------- 1: $str = $post-&gt;post_content; 2: assert( isset( $str ) ); 3: assert( is_string( $str ) ); 4: echo $str; 5: $str = 'before &lt;img src="/path/to/nonexistant.gif" /&gt; after'; 6: assert( isset( $str ) ); 7: echo $str; -------------------- </code></pre> <p>Outputs this...</p> <pre><code>------ Output ------ before &lt;img src="/path/to/valid_img.gif" /&gt; after before &lt;img src="/path/to/nonexistant.gif" /&gt; after -------------------- </code></pre> <p>With these warnings...</p> <pre><code>--- PHP Warnings --- PHP Warning: assert() [&lt;a href='function.assert'&gt;function.assert&lt;/a&gt;]: Assertion failed in /path/to/header.php on line 2 PHP Warning: assert() [&lt;a href='function.assert'&gt;function.assert&lt;/a&gt;]: Assertion failed in /path/to/header.php on line 3 -------------------- </code></pre> <p>Why would line 4 properly echo the $str if assert() fails twice when I KNOW 100% it should succeed?</p> <p>What does a broken image src have to do with setting or unsetting the variable $str? WordPress bug/oddity?</p> <p><strong>Now the crazy part...</strong></p> <p>When lines 5-7 are commented out, thus eliminating the nonexistant.gif, the assert() warning does NOT appear and the output STILL properly produces this...</p> <pre><code>------ Output ------ before &lt;img src="/path/to/valid_img.gif" /&gt; after -------------------- </code></pre> <p>Any chance you can reproduce this and tell me what you think? I'm new to PHP, but I'm pretty sure this is crazyness. :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload