@anonymous-piwik-user opened this Issue on February 11th 2013

Hi,

when the Document Root of Piwik lies on a Network Share under Windows, the PDF Reports throw errors when using functions like imagettftext(), imagettfbbox(), etc:

Warning: imagettfbbox(): Could not find/open font in \\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\libs\pChart2.1.3\class\pImage.class.php on line 211

Backtrace -->

<a href='/0'>#0</a> Piwik_ErrorHandler(...) called at [:]
<a href='/1'>#1</a> imagettfbbox(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\libs\pChart2.1.3\class\pImage.class.php:211]
<a href='/2'>#2</a> pImage->getTextBox(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\libs\pChart2.1.3\class\pDraw.class.php:988]
<a href='/3'>#3</a> pDraw->drawText(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\ImageGraph\StaticGraph.php:282]
<a href='/4'>#4</a> Piwik_ImageGraph_StaticGraph->getTextWidthHeight(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\ImageGraph\StaticGraph.php:300]
<a href='/5'>#5</a> Piwik_ImageGraph_StaticGraph->getMaximumTextWidthHeight(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\ImageGraph\StaticGraph\GridGraph.php:376]
<a href='/6'>#6</a> Piwik_ImageGraph_StaticGraph_GridGraph->getGridLeftMargin(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\ImageGraph\StaticGraph\GridGraph.php:87]
<a href='/7'>#7</a> Piwik_ImageGraph_StaticGraph_GridGraph->initGridChart(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\ImageGraph\StaticGraph\Evolution.php:29]
<a href='/8'>#8</a> Piwik_ImageGraph_StaticGraph_Evolution->renderGraph(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\ImageGraph\API.php:513]
<a href='/9'>#9</a> Piwik_ImageGraph_API->get(...) called at [:]
<a href='/10'>#10</a> call_user_func_array(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\core\API\Proxy.php:190]
<a href='/11'>#11</a> Piwik_API_Proxy->call(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\core\API\Request.php:128]
<a href='/12'>#12</a> Piwik_API_Request->process(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\core\ReportRenderer.php:242]
<a href='/13'>#13</a> Piwik_ReportRenderer::getStaticGraph(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\core\ReportRenderer\Html.php:144]
<a href='/14'>#14</a> Piwik_ReportRenderer_Html->renderReport(...) called at [:]
<a href='/15'>#15</a> array_walk(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\PDFReports\API.php:440]
<a href='/16'>#16</a> Piwik_PDFReports_API->generateReport(...) called at [:]
<a href='/17'>#17</a> call_user_func_array(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\core\API\Proxy.php:190]
<a href='/18'>#18</a> Piwik_API_Proxy->call(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\core\API\Request.php:128]
<a href='/19'>#19</a> Piwik_API_Request->process(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\plugins\API\Controller.php:27]
<a href='/20'>#20</a> Piwik_API_Controller->index(...) called at [:]
<a href='/21'>#21</a> call_user_func_array(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\core\FrontController.php:138]
<a href='/22'>#22</a> Piwik_FrontController->dispatch(...) called at [\\10.24.4.5\WWW-EXTRA$\piwik\current\piwik\index.php:61]

Problem is, that imagettftext() doesn't seem to handle UNC paths for the font file, which resolves to \\10.24.4.5\WWW-EXTRA$\piwik\current\piwik/plugins/ImageGraph/fonts/tahoma.ttf
(Also see http://www.php.net/manual/en/function.imagettfbbox.php#91050 )

I don't know if a solution is necessary, I made a workaround to set a new PIWIK_INCLUDE_PATH in bootstrap.php:

define("PIWIK_INCLUDE_PATH", str_replace("\\\\", "//", PIWIK_DOCUMENT_ROOT));

Otherwise a solution would be to change the API::getFontPath() to rewrite Paths beginning with \\ to //?

@mattab commented on February 15th 2013 Owner

Thanks for the report. If only the imagettf* functions are affected, and if all of them use the path from getFontPath then it would be great to patch this function with the str_replace you proposed! please subit pull request or patch :)

Powered by GitHub Issue Mirror