CGI::A...arGraph(3pm)

πŸ“¦
version 0.07 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

CGI::Application::Plugin::DBIProfile::Graph::HTMLBarGraph β€” okay so basically, if it weren't for HTML::BarGraph bugs, this would work. 🫠

This is a perl module, bestie, from the User Contributed Perl Documentation, and today we are going to talk about it. Sit down, hydrate, it's a whole thing. ✨


πŸ›‘ DO NOT USE THIS πŸ›‘

No seriously. Do not use this. πŸ™ˆ

It exists for exactly two reasons, and neither of them is "you should run it in prod":

  1. It's here because somebody already wrote it (hi, that was the author), and
  2. It gives you another example to look at. ✨

But β€” and this is the part where we all hold hands β€” there are bugs in HTML::BarGraph. Like, the module this one leans on is the problem, not this one. πŸ’€

The tea is: if HTML::BarGraph ever gets fixed, this will start to work correctly. πŸŽ€ Until then it's giving "beautiful dream, no follow-through."

The actual issue? It's the use of globals to track things like $maxval, which throws off the scaling of the graph for subsequent calls to graph(). So the first graph is fine and then everything after that is a mess. Not iconic. Not slay. 😭


πŸ’€ BUGS πŸ’€

Okay so, the bug report, but make it a group chat rant:

  • HTML::BarGraph is not mod_perl safe. It has globals that track, for instance, $maxval. 🚩
  • That global doesn't get reset across calls to graph(), so whatever your largest value graphed is, that will set the scale of all graphs to come. Your tiny little numbers are getting stretched to fit a chart from three requests ago. main character energy from a variable that should not have it. πŸ‘‘
  • And honestly? Actually, it's not even single process safe... you can't make more than one call to graph(). Not two. One. That's the whole budget. 🫢
Lowkey this is why we don't use package globals for state, bestie. Highkey. πŸ¦‹

🌸 SEE ALSO 🌸

  • CGI::Application::Plugin::DBIProfile β€” the actual parent module, go look at that one instead, it's the moment. πŸ’–

πŸŽ€ AUTHOR πŸŽ€

Joshua I Miller, unrtst@cpan.org πŸ’Œ


Copyright 2007 Joshua Miller, all rights reserved. ⭐

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. 🌈


Okay that's the whole page, bestie, you read all of it, proud of you. πŸ’œ This little artifact is CGI::A...arGraph(3pm) (the truncated title, she's mysterious like that), and it came from perl v5.36.0, dated 2022-11-19. πŸ¦‹ Go forth, don't call graph() twice, and slay responsibly. πŸ’…βœ¨

πŸ“¦ where this page comes from