PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 9, 2022

[FIXED] Extra line in response of generated CSV in Symfony2

 February 09, 2022     response, symfony     No comments   

Issue

I have a code that generates a CSV file, using Response but I got an extra data which I woudl like to elminate, this extra data is: <! -- STRACE__TIMER__BREAK --> At this time Im not sure if is PHP or the server. Someone has any idea why is happining this issue?

My code:

    $rows = array();
    foreach ($entities as $entity) {
         $data = ........  // here is the array //
         $rows[] = implode(';', $data);
    }
    $content = implode("\n", $rows);

    $response = new Response($content);
    $response->headers->set('Content-Type', 'text/csv');
    $response->headers->set('Content-Disposition', $filename);

    return $response;

The file appears like this:

31/03/2021;1;03;2183752;06140809820010;CREDOMATIC, S.A. DE C.V.;0.00;0.00;0.00;3.78;0.00;0.00;0.49;4.27;3 31/03/2021;1;03;2183851;06140809820010;CREDOMATIC, S.A. DE C.V.;0.00;0.00;0.00;70.89;0.00;0.00;9.22;80.11;3 31/03/2021;1;03;2325856;06140809820010;CREDOMATIC, S.A. DE C.V.;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;3 31/03/2021;1;03;2325857;06140809820010;CREDOMATIC, S.A. DE C.V.;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00;3 <! -- STRACE__TIMER__BREAK -->


Solution

Strangely, I found that line in the config file app.php

/* START HOST DEBUG CODE */
class LastSay
{
    public function __construct()
    {
        $ipList = array('67.23.232.183','72.29.91.30', '67.23.232.178', '2607:fcd8:a:5:ce9b:a1b2:b2f6:6b7c');
        if( in_array( $_SERVER['REMOTE_ADDR'] , $ipList ) ) 
        {
            file_put_contents("hdpid.txt", getmypid());
            if(!isset($_GET['fast']))
              sleep(10);
        }
    }

    public function __destruct()
    {
        echo "<!-- STRACE__TIMER__BREAK -->";
    }
}
$varNameDoesntMatter = new LastSay();
/* END HOST DEBUG CODE */

I just removed it.



Answered By - Pedro Elias Aguilar
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing