[mapserver-users] PHP $imgObj->saveImage(null) sends headers - Found word(s) list error in the Text body [Keyword]

Miloslav Kmeť miloslav.kmet at gmail.com
Tue Apr 6 03:47:33 EDT 2010


Don't know, whether to call this bug or behavior, but I can confirm this also 
on 
PHP 5.2.6-1+lenny8 with Suhosin-Patch 0.9.6.2 (cli) (built: Mar 14 2010 
08:14:04)  with the latest mapscript from SVN and also with the last 5.6.3 
release.

I have no idea, wheter that php_header call was in 5.6.0, or why you didn't 
get that error.

Thanks

On pondelok 05 Apríl 2010 22:05:23 Pavel Iacovlev wrote:
> I get no errors with your code, and yes I have header() before output,
> I use it with Zend Framework so it does the same thing with headers as
> symphony does.
> 
> PHP 5.2.4-2ubuntu5.10 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan  6
> 2010 22:01:14)
> MapScript: 5.6.0 (will compile latest and test against it)
> 
> Error reporting:
> error_reporting(E_ALL | E_STRICT);
> ini_set('display_startup_errors', 1);
> ini_set('display_errors', 1);
> 
> 2010/4/5 Miloslav Kmeť <miloslav.kmet at gmail.com>:
> > Hi I am sure, that I get an error with the latest code in this branch:
> > https://svn.osgeo.org/mapserver/branches/branch-5-6/mapserver
> > 
> > My PHP version is 5.3.2.
> > 
> > Try this simple frameworkless php code:
> > 
> > <?php
> > error_reporting(E_ALL);
> > ini_set('display_errors', 'on');
> > $map = ms_newMapObj('./test.map'); // select your usual mapfile
> > $img = $map->draw();
> > 
> > ob_start();
> > $img->saveImage(null);
> > $data = ob_get_clean();
> > 
> > header('Content-type: image/jpeg');
> > echo $data;
> > ?>
> > 
> > The error is:
> > Warning: Cannot modify header information - headers already sent in
> > /www/test/buffer/mapserver/ob-reproduce.php on line 11
> > 
> > I do not have a problem with collecting the data or using them. The
> > problem is to send headers after $img->saveImage(null) call.
> > 
> > Because of the symfony's framework behaviour - controller creates the
> > data and the response later send them with additional headers I cannot
> > send the headers before $img->saveImage();
> > 
> > If you change your code and puts the header('Content-type: image/png');
> > before imagepng($image); you will see that error.
> > 
> > Thank you for giving a try.
> > 
> > On pondelok 05 Apríl 2010 19:37:02 you wrote:
> >> Oh sorry, your code is correct thought you used ob_end_clean and you
> >> are using ob_get_clean. But the snippet works for me with out any
> >> phpmapscript modification.
> >> 
> >> 2010/4/5 Pavel Iacovlev <iacovlev.pavel at gmail.com>:
> >> > 1) Your php code is not correct I think, ob_get_clean  just cleans the
> >> > output and does not return the captured content.
> >> > 2) Try with no framework, maybe it sends some headers before you run
> >> > your code.
> >> > 
> >> > This works for me in Zend Framework in MVC mode, should work for
> >> > symfony too. ob_start();
> >> > $image->saveimage('');
> >> > $image = imagecreatefromstring(ob_get_contents());
> >> > ob_end_clean();
> >> > imagepng($image);
> >> > 
> >> > 2010/4/5 Miloslav Kmeť <miloslav.kmet at gmail.com>:
> >> >> Hi. I am trying to use php_mapscript in MVC framework (symfony) and I
> >> >> want to catch the output of $imgObje->saveImage(null); for the later
> >> >> processing, eg: using the builtin cache mechanism instead of directly
> >> >> writing the file to the cache.
> >> >> 
> >> >> My code very simplified looks like:
> >> >> 
> >> >> ob_start();                            // start output buffering
> >> >> $imgObj->saveImage(null);  // print output to std
> >> >> $image = ob_get_clean();   // get the buffer and clen it
> >> >> 
> >> >> header('Content-type: image/jpeg'); // setting the header
> >> >> echo $image; // printing the image
> >> >> 
> >> >> At the header line I got an header already sended error, even no
> >> >> output will be brinted before.
> >> >> 
> >> >> I looked into php_mapscript.c and I found that in the saveImage
> >> >> function there is php_header(TSRMLS_C); As I do not know the PHP
> >> >> internals, i do not know what that call is doing, but when I removed
> >> >> it out, and recompiled the extension,
> >> >> 
> >> >> Now output buffering is working correctly.
> >> >> 
> >> >> What is the function doing? Should it be replaced in the main
> >> >> development?
> >> >> 
> >> >> Thanks
> >> >> --
> >> >> Miloslav Kmeť
> >> >> 
> >> >> _______________________________________________
> >> >> mapserver-users mailing list
> >> >> mapserver-users at lists.osgeo.org
> >> >> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >> > 
> >> > --
> >> > http://iap.md, The future is open
> > 
> > --
> > Miloslav Kmeť
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users

-- 
Miloslav Kmeť
Banská Bystrica


More information about the mapserver-users mailing list