We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13218
    • 134 Posts
    Hi all,
    this is pretty strange, at least to me.
    I have a snippet that creates content, puts it in a chunk A. This chunk A it puts into another chunk B.
    Chunk B output now contains a BOM (  ) in the beginning of where chunk A output is inserted.
    This BOM is not in the chunk itself, which is inside the database.

    I only know this BOM-thing from including files. But files are not used here (as far as i know - everything is uncached, so it's created directly from the database).
    This is a very common procedure, i used it dozens of times in this site. But it happens at only two places. I couldn't find anything different there, though.

    So, in don't even know where to start looking. It probably is some stupid thing that maybe happens at some other part of the process, but where i wouldn't know.

    Any ideas? Pllleeeaaaasse?
      @itWilllBeOK
    • Perhaps it's in the snippet? Or if you use CodeMirror it could be a hidden character in either of them (you said the chunk was in the database, but not if you also checked the database directly).
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 13218
        • 134 Posts
        I'll check that in a minute, Mark.
        My dog wants to go outside and:
        my dogs ideas > what i gotta do.
          @itWilllBeOK
          • 13218
          • 134 Posts
          Well, if you thought i couldn't get any weirder...

          I couldn't find any BOMs in the database. But check this:
          $d = array();
          // Line A
          $d['newslist'] = $modx->runSnippet('getNewsList', array( parentid => 99, lang => $lang, showDate => '' )); 
           // Line B
          $d['jobreport'] = $modx->runSnippet('getJobreport', array( lang => $lang ));
          // Line C ( same as line A )
          // $d['newslist'] = $modx->runSnippet('getNewsList', array( parentid => 99, lang => $lang, showDate => '' )); 
          
          // CHECK FOR BOMS
          $bom = pack("CCC", 0xef, 0xbb, 0xbf);
          //check newslist for BOM
          if (strstr($d['newslist'], $bom) !== false) {
          	$d['newslist'] = 'BOM'.$d['newslist'];
          }
          // check jobreport for BOM
          if (strstr($d['jobreport'], $bom) !== false) {
          	$d['jobreport'] = 'BOM'.$d['jobreport'];
          }



          I call two snippets, in line A and B. After this call, $d['newslist'] contains a BOM. Strange thing is, when i check for the BOM *inside* the snippetcall 'getNewsList', immediately before the return-call, there is no BOM! So it somehow gets added in the above script.

          To make it even stranger, when i uncomment Line C, in effect the same as Line A, everything is fine.
          And when i comment out Line A or A+C, the BOM now appears in $d['jobreport'], called from Line B.

          I don't even expect you to follow through all of this, it just makes no sense, at least to me.

          I think i'll just search and replace the BOMs in the final output. It's not pretty, but i already spent too much time on this...

          Thanks for watching, good night.
            @itWilllBeOK