Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduled reports: allow reading font from UNC share, preven "Could not find/open font" #3750

Closed
anonymous-matomo-user opened this issue Feb 11, 2013 · 2 comments
Labels
answered For when a question was asked and we referred to forum or answered it. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.

Comments

@anonymous-matomo-user
Copy link

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 -->

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

mattab commented Feb 15, 2013

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 :)

@anonymous-matomo-user anonymous-matomo-user added this to the Future releases milestone Jul 8, 2014
@mattab mattab modified the milestones: Long term, Mid term Dec 23, 2015
@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016
@mattab
Copy link
Member

mattab commented Jul 1, 2019

Thanks for contributing to this issue. As it has been a few months since the last activity and we believe this is likely not an issue anymore, we will now close this. If that's not the case, please do feel free to either reopen this issue or open a new one. We will gladly take a look again!

@mattab mattab closed this as completed Jul 1, 2019
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it. Task Indicates an issue is neither a feature nor a bug and it's purely a "technical" change.
Projects
None yet
Development

No branches or pull requests

2 participants