29

[CMS of Doom™]
The gift that keeps on giving...
When you think you've seen it all after 7 months in legacy hell, you get another gift:

Let's say you use PHP, but your IQ is in the zero-ish range, then it is obvious to:
- use define() for constants in all your config.*.php files
- then include said config.*.php files multiple times
- and because define() doesn't overwrite the same constant, because it's - you know - a constant, you instead of including just do a file_get_contents() to read the PHP file as string and then parse the values by Regex.

The dev who wrote this was truly one of the devs ever.

Comments
  • 11
    (never mind the line numbers, it's normal in this "project")
  • 7
    I find the most bizarre elements of legacy code isn't down to one coder fixing an issue in an odd way, but over time probably 10 different coders over many years all trying to add / correct bits that the company has latched on to an aging system.

    The lack of (at the very least) a "require_once" is, however quite shocking.
  • 11
    … wow
    just … wow
    All this effort to replace a language feature called include_once().
    It‘s beyond me how that person did not find that but any other way.
  • 9
    The deviest of them all.
  • 1
    This is hilarious 😂
    I‘m sorry for you because you have to deal with this pile of horse shit.
  • 3
    PHP, where just because we can, it don't mean we should, but mfkers still do anyways.

    I feel for your pain.

    That line count man....
  • 8
    Yup.
    I sat with the "automation expert" to see what he was up to.

    Fucking idiot was asking me how to use pyaml to parse the cicd file to get the EnvVars values. In the process triggerd in the same cicd job.
    It went like this:
    "Have you ever used Enviriment vars" "Yes!" "So what are trying to do again?" "Get the vars for my process by reading them from the cicd file!" "Have you ever used Enviroment.... never mind. I give up"
  • 2
    @PonySlaystation

    So to prevent overriding or getting a wrong value we parse via regex the config file which is set in a variable $configfile which could be overwritten from anywhere...

    Remarkable. Though I admit I'd rather expected to see a direct call to the php binary to include file and run serialize with get_defined_vars - captured from stdout and then unserialized for usage.

    Hope I remembered it correctly - think it was PHP -r to directly execute code.

    🎉

    @magicMirror

    But. That's heretical magic. No one understands that.

    Config files must be read, otherwise where do da values come from?

    Potatoes?
  • 1
    @IntrusionCM bwahahahaha that PHP binary call would be a much cleaner solution since it wouldn't require some whacky Regex...
    Anyway, I've refactored all config files and removed every define().
  • 1
    Why is this block in the middle of nowhere?
  • 3
    @TeachMeCode I've put some line breaks before and after just for the screenshot to remove other ugly distractions, the line numbers are real though.
  • 1
    This is truly one of the codes ever written
Add Comment