[TYPO3] Strange PHP string problem

Wiel, J.A.M van de j.a.m.v.d.wiel at tue.nl
Thu Oct 2 14:49:02 CEST 2008


Hi list,
Strange how one usually finds the solution to a problem after asking for help.. It turns out something goes very wrong when the length of a single line of HTML code passes a certain threshold. Things work as expected by adding a simple "\n" to every table row.. Still I don't know whether my browser is to blame (Firefox 3.0.3 Linux), or if it's something in the way TYPO3 handles the string returned from a frontend plugin..

Bas


-----Original Message-----
From: typo3-english-bounces at lists.netfielders.de on behalf of Wiel, J.A.M van de
Sent: Thu 10/2/2008 13:16
To: typo3-english at lists.netfielders.de
Subject: [TYPO3] Strange PHP string problem
 
Hello all,
The past few days I've been pulling my hair out over some really strange issue. I'm trying to get some data from a web service using Nusoap (eim2nusoap) and return this to the user as a HTML table. It's a really simple price list, so nothing fancy when it comes to formatting. I'm simply cleaning up (for presentation) and concatenating some field values and markup into a single large string that forms a number of HTML tables. So far, so good and it works properly up to a point.

I'm outputting a set of three-column tables. One for a product description, one for a unit type, and one for price per unit. The cleaning up consists of replacing a '.' in the price per unit with a ',' and sticking the Euro symbol and a space in front of it if the price is a number. The principle is like this, as part of a foreach loop:

$articleTable .= '<tr><td class="article">'.$article['Description'].'</td><td>'.$article['Unit'].'</td><td class="price">'.$this->cleanUpPrice($article['Price']).'</td></tr>';

The $this->cleanUpPrice function simiply does a str_replace('.',',',$articlePrice); and concatenates itself with a euro symbol entity like $articlePrice = '&euro; '.$articlePrice;

This works well up to a certain point and then it fails in a very strange way. When I leave out the $articlePrice = '&euro; '.$articlePrice; bit, things work perfectly. When I add it, TYPO3 seems to simply skip over the entire page rendering and returns only the red 'PREVIEW' box in my browser.

What's weird about this is that I can replace the '&euro; ' bit with any combination of 3 regular characters and it'll work. As soon as I put more than 3 characters between the single quotes, it fails and PHP reports nothing to the error log even with error_reporting(E_ALL).

The weirdness continues though, because if I keep the cleanup stuff for the price as it should be, I can actually get a proper result but only if I remove the class attributes from the table cells. If I keep the class attributes, TYPO3 gives me the same strange behavior..

I'm beginning to suspect some kind of buffer overflow but that would be strange. I'm only outputting around 200 short table rows. Surely TYPO3 should be able to deal with that?

When I use t3lib_div::debug to give me the end result just before my plugin's main() function returns it, the string is perfectly valid (leading me to believe I'm not doing anything bad on the PHP side). It even validates perfectly when I manually paste it into a dummy page. TYPO3 appears to choke on it later though and I don't see how I should start debugging that.

Thanks for reading my long mail so far! Any help would be greatly appreciated!

Bas
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.netfielders.de
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english



More information about the TYPO3-english mailing list