KlausK
16.10.2012, 20:03
Da ich den Banner-Manager meines Gambio GX I kaum nutze, habe ich irgendwann durch Zufall festgestellt, dass dort im Backend Warnungen ausgegeben werden:
WARNING(2): "imagefontheight() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:679 (Details)
WARNING(2): "imagefontheight() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:683 (Details)
WARNING(2): "imagefontwidth() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:684 (Details)
WARNING(2): "imagestring() expects parameter 2 to be long, string given" in /admin/includes/classes/phplot.php:693 (Details)
WARNING(2): "imagefontheight() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:679 (Details)
und so weiter
Das ist zwar nix schlimmes. Wenn man aber erstmal gefühlte 100 Zeilen runterscrollen muss, dann wird's doch nervig.
Ich gehe davon aus, dass sich das Problem irgendwann im Zuge zahlreicher Updates und ServicePacks für den Shop, sowie Updates meines PHP-Interpreters ergeben hat.
Das Problem ist übrigens gar nicht mal selten und betrifft offenbar viele Shops, vermutlich aller xtc: Derivate!
Auf der Suche in den tiefen des Netzes bin ich irgendwann auf eine für mich passende Lösung gestossen.
Verantwortlich ist das Script /admin/includes/classes/phplot.php
Der Author hatte offenbar nur einige Variablen aus der Funktion DrawText entfernt und in der Funktion number_format die ersten beiden Parameter auf den Datentyp Double gesetzt.
Warum diese Vorgehensweise zur Problembehebung führt, konnte ich bisher mangels Interesse, Zeit und tiefer gehender PHP-Kenntnisse nicht nachvollziehen. Vielleicht kann das ja mal einer genau erklären :D
Das war mir in diesem Fall aber auch wurscht. Hauptsache die Meldungen sind weg und der Shop läuft noch!
Sicherungskopie anlegen und öffnen: /admin/includes/classes/phplot.php
Ab Zeile 665 bis 703 diese Funktion DrawText
function DrawText($which_font,$which_angle,$which_xpos,$whi ch_ypos,$which_color,$which_size,$which_text,$whic h_halign='left',$which_valign='') {
if ($this->use_ttf == 1 ) {
$size = $this->TTFBBoxSize($which_size, $which_angle, $which_font, $which_text);
if ($which_valign == 'bottom') {
$which_ypos = $which_ypos + ImageFontHeight($which_font);
}
if ($which_halign == 'center') {
$which_xpos = $which_xpos - $size[0]/2;
}
ImageTTFText($this->img, $which_size, $which_angle,
$which_xpos, $which_ypos, $which_color, $which_font, $which_text);
} else {
if ($which_valign == 'top') {
$which_ypos = $which_ypos - ImageFontHeight($which_font);
}
$which_text = ereg_replace("\r","",$which_text);
$str = split("\n",$which_text); //multiple lines submitted by Remi Ricard
$height = ImageFontHeight($which_font);
$width = ImageFontWidth($which_font);
if ($which_angle == 90) { //Vertical Code Submitted by Marlin Viss
for($i=0;$i<count($str);$i++) {
ImageStringUp($this->img, $which_font, ($i*$height + $which_xpos), $which_ypos, $str[$i], $which_color);
}
} else {
for($i=0;$i<count($str);$i++) {
if ($which_halign == 'center') {
$xpos = $which_xpos - strlen($str[$i]) * $width/2;
ImageString($this->img, $which_font, $xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
} else {
ImageString($this->img, $which_font, $which_xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
}
}
}
}
return true;
}
mit dieser ersetzen oder die Zeilen entsprechend auskommentieren
function DrawText($which_font,$which_angle,$which_xpos,$whi ch_ypos,$which_color,$which_size,$which_text,$whic h_halign='left',$which_valign='') {
if ($this->use_ttf == 1 ) {
$size = $this->TTFBBoxSize($which_size, $which_angle, $which_font, $which_text);
if ($which_valign == 'bottom') {
$which_ypos = $which_ypos + ImageFontHeight($which_font);
}
if ($which_halign == 'center') {
$which_xpos = $which_xpos - $size[0]/2;
}
ImageTTFText($this->img, $which_size, $which_angle,
$which_xpos, $which_ypos, $which_color, $which_font, $which_text);
} else {
// if ($which_valign == 'top') {
// $which_ypos = $which_ypos - ImageFontHeight($which_font);
// }
$which_text = ereg_replace("\r","",$which_text);
$str = split("\n",$which_text); //multiple lines submitted by Remi Ricard
// $height = ImageFontHeight($which_font);
// $width = ImageFontWidth($which_font);
if ($which_angle == 90) { //Vertical Code Submitted by Marlin Viss
for($i=0;$i<count($str);$i++) {
ImageStringUp($this->img, $which_font, ($i*$height + $which_xpos), $which_ypos, $str[$i], $which_color);
}
} else {
for($i=0;$i<count($str);$i++) {
if ($which_halign == 'center') {
$xpos = $which_xpos - strlen($str[$i]) * $width/2;
// ImageString($this->img, $which_font, $xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
} else {
ImageString($this->img, $which_font, $which_xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
}
}
}
}
return true;
}
Zeile 1163
$ylab = number_format($this->max_y, $this->y_precision, ".", ",") . $this->si_units . ".";
Hiermit ersetzen
$ylab = number_format((double)$this->max_y, (double)$this->y_precision, ".", ",") . $this->si_units . ".";
Zeile 1528
$xlab = number_format($this->plot_min_x,$this->x_precision,".",",") . "$this->si_units";
Hiermit ersetzen
$xlab = number_format((double)$this->plot_min_x,(double)$this->x_precision,".",",") . "$this->si_units";
Zeile 1576
$xlab = number_format($x_tmp,$this->x_precision,".",",") . "$this->si_units";
Hiermit ersetzen
$xlab = number_format((double)$x_tmp,(double)$this->x_precision,".",",") . "$this->si_units";
Zeile 1623
$ylab = number_format($which_ylab,$this->y_precision,".",",") . "$this->si_units";
Hiermit ersetzen
$ylab = number_format((double)$which_ylab,(double)$this->y_precision,".",",") . "$this->si_units";
Zeile 1906
$label_txt = number_format(($val / $total * 100), $this->y_precision, ".", ",") . "%";
Hiermit ersetzen
$label_txt = number_format(($val / $total * 100), (double)$this->y_precision, ".", ",") . "%";
Speichern und Seite neu laden. Nun sollten alle Warnungen weg sein.
WARNING(2): "imagefontheight() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:679 (Details)
WARNING(2): "imagefontheight() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:683 (Details)
WARNING(2): "imagefontwidth() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:684 (Details)
WARNING(2): "imagestring() expects parameter 2 to be long, string given" in /admin/includes/classes/phplot.php:693 (Details)
WARNING(2): "imagefontheight() expects parameter 1 to be long, string given" in /admin/includes/classes/phplot.php:679 (Details)
und so weiter
Das ist zwar nix schlimmes. Wenn man aber erstmal gefühlte 100 Zeilen runterscrollen muss, dann wird's doch nervig.
Ich gehe davon aus, dass sich das Problem irgendwann im Zuge zahlreicher Updates und ServicePacks für den Shop, sowie Updates meines PHP-Interpreters ergeben hat.
Das Problem ist übrigens gar nicht mal selten und betrifft offenbar viele Shops, vermutlich aller xtc: Derivate!
Auf der Suche in den tiefen des Netzes bin ich irgendwann auf eine für mich passende Lösung gestossen.
Verantwortlich ist das Script /admin/includes/classes/phplot.php
Der Author hatte offenbar nur einige Variablen aus der Funktion DrawText entfernt und in der Funktion number_format die ersten beiden Parameter auf den Datentyp Double gesetzt.
Warum diese Vorgehensweise zur Problembehebung führt, konnte ich bisher mangels Interesse, Zeit und tiefer gehender PHP-Kenntnisse nicht nachvollziehen. Vielleicht kann das ja mal einer genau erklären :D
Das war mir in diesem Fall aber auch wurscht. Hauptsache die Meldungen sind weg und der Shop läuft noch!
Sicherungskopie anlegen und öffnen: /admin/includes/classes/phplot.php
Ab Zeile 665 bis 703 diese Funktion DrawText
function DrawText($which_font,$which_angle,$which_xpos,$whi ch_ypos,$which_color,$which_size,$which_text,$whic h_halign='left',$which_valign='') {
if ($this->use_ttf == 1 ) {
$size = $this->TTFBBoxSize($which_size, $which_angle, $which_font, $which_text);
if ($which_valign == 'bottom') {
$which_ypos = $which_ypos + ImageFontHeight($which_font);
}
if ($which_halign == 'center') {
$which_xpos = $which_xpos - $size[0]/2;
}
ImageTTFText($this->img, $which_size, $which_angle,
$which_xpos, $which_ypos, $which_color, $which_font, $which_text);
} else {
if ($which_valign == 'top') {
$which_ypos = $which_ypos - ImageFontHeight($which_font);
}
$which_text = ereg_replace("\r","",$which_text);
$str = split("\n",$which_text); //multiple lines submitted by Remi Ricard
$height = ImageFontHeight($which_font);
$width = ImageFontWidth($which_font);
if ($which_angle == 90) { //Vertical Code Submitted by Marlin Viss
for($i=0;$i<count($str);$i++) {
ImageStringUp($this->img, $which_font, ($i*$height + $which_xpos), $which_ypos, $str[$i], $which_color);
}
} else {
for($i=0;$i<count($str);$i++) {
if ($which_halign == 'center') {
$xpos = $which_xpos - strlen($str[$i]) * $width/2;
ImageString($this->img, $which_font, $xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
} else {
ImageString($this->img, $which_font, $which_xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
}
}
}
}
return true;
}
mit dieser ersetzen oder die Zeilen entsprechend auskommentieren
function DrawText($which_font,$which_angle,$which_xpos,$whi ch_ypos,$which_color,$which_size,$which_text,$whic h_halign='left',$which_valign='') {
if ($this->use_ttf == 1 ) {
$size = $this->TTFBBoxSize($which_size, $which_angle, $which_font, $which_text);
if ($which_valign == 'bottom') {
$which_ypos = $which_ypos + ImageFontHeight($which_font);
}
if ($which_halign == 'center') {
$which_xpos = $which_xpos - $size[0]/2;
}
ImageTTFText($this->img, $which_size, $which_angle,
$which_xpos, $which_ypos, $which_color, $which_font, $which_text);
} else {
// if ($which_valign == 'top') {
// $which_ypos = $which_ypos - ImageFontHeight($which_font);
// }
$which_text = ereg_replace("\r","",$which_text);
$str = split("\n",$which_text); //multiple lines submitted by Remi Ricard
// $height = ImageFontHeight($which_font);
// $width = ImageFontWidth($which_font);
if ($which_angle == 90) { //Vertical Code Submitted by Marlin Viss
for($i=0;$i<count($str);$i++) {
ImageStringUp($this->img, $which_font, ($i*$height + $which_xpos), $which_ypos, $str[$i], $which_color);
}
} else {
for($i=0;$i<count($str);$i++) {
if ($which_halign == 'center') {
$xpos = $which_xpos - strlen($str[$i]) * $width/2;
// ImageString($this->img, $which_font, $xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
} else {
ImageString($this->img, $which_font, $which_xpos, ($i*$height + $which_ypos), $str[$i], $which_color);
}
}
}
}
return true;
}
Zeile 1163
$ylab = number_format($this->max_y, $this->y_precision, ".", ",") . $this->si_units . ".";
Hiermit ersetzen
$ylab = number_format((double)$this->max_y, (double)$this->y_precision, ".", ",") . $this->si_units . ".";
Zeile 1528
$xlab = number_format($this->plot_min_x,$this->x_precision,".",",") . "$this->si_units";
Hiermit ersetzen
$xlab = number_format((double)$this->plot_min_x,(double)$this->x_precision,".",",") . "$this->si_units";
Zeile 1576
$xlab = number_format($x_tmp,$this->x_precision,".",",") . "$this->si_units";
Hiermit ersetzen
$xlab = number_format((double)$x_tmp,(double)$this->x_precision,".",",") . "$this->si_units";
Zeile 1623
$ylab = number_format($which_ylab,$this->y_precision,".",",") . "$this->si_units";
Hiermit ersetzen
$ylab = number_format((double)$which_ylab,(double)$this->y_precision,".",",") . "$this->si_units";
Zeile 1906
$label_txt = number_format(($val / $total * 100), $this->y_precision, ".", ",") . "%";
Hiermit ersetzen
$label_txt = number_format(($val / $total * 100), (double)$this->y_precision, ".", ",") . "%";
Speichern und Seite neu laden. Nun sollten alle Warnungen weg sein.