0

I use php templates when I need to send notification emails to multiple people. Since upgrading to EE 2.10, I have noticed that when I echo the code, before the code that I am echoing, there is a random code in {}, ex. {!-- ra:0000000004854f7300007f40072103c3 --}.

Any idea what this code is and how I can remove it?

I also use php templates to download data/save it to csv. this same random code is always in the first cell of the .csv file.

Any help is appreciated.

Below is a sample of the php template code I am referring too.

<?php
            $debug = true; //debug mode: true for on, false for off
            $id = $this->EE->security->xss_clean($this->EE->uri->segment(3, 0)); 
            if( $id > 0 && is_numeric($id) ) //check if id is numeric and greater than 0
            {
                $this->EE->load->library('email');
                $this->EE->load->helper('text');
                $sql = "SELECT 
                        et.title AS TITLE,
                        ed.field_id_6 AS MY_VAR
                        FROM 
                        exp_channel_data as ed          
                        WHERE ed.entry_id = " . $id . "  LIMIT 1";

            $results = $this->EE->db->query($sql);
            if ($results->num_rows() > 0)
                {   
                    $title = $results->row('TITLE');
                    $myVar1 = $results->row('MY_VAR');
                } // END line 29

            if($debug == TRUE)
                { 
                    echo "46";
                    echo $title."<br />\n";
                    echo $myVar1."<br />\n";
                }

} // END line 5 exit();

?>

  • I knew I left out a detail. Where I see t his {random string code} is in the browser. – user1469 Nov 18 '15 at 19:53
1

This has to do with the new template parser introduced in EE 2.9.0. What you're seeing is a template annotation, and it's removed from the template late in the parsing process. Since you're manually calling exit(), it never gets the chance to do so.

My advice: turn this code into a simple plugin instead. This amount of PHP in a template is always trouble waiting to happen IMHO.

| improve this answer | |
  • Or, the lazy bad practice solution: just remove the exit(). That fixed an old script I had hanging around that went wrong on upgrade. – richplane Feb 12 '19 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.