We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    Ok dev people... I was asked to look into an aging site and make a "quick change" -- haha. The code is ghoulishly bad... spaghetti everywhere. Here’s what I cannot figure out... the page in question uses 3 include files, and it calls one function which reads custom form definitions right out of the $GLOBALS array, e.g.

    $myform = $GLOBALS['forms']['myform'];


    Ok, that’s not how I would have done it, but ok. But I cannot for the life of me see where they @#%@#^ this data was ENTERED into the $GLOBALS array. There are only 3 files involved here, and none of them write anything to the $GLOBALS array that I can see.

    Am I blind? Or is there some other way that values got populated in there? The included files don’t include other files, so I think I’ve tracked down all PHP code involved in producing this one page. But I remain baffled.

    Any thoughts?
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: Everett at Mar 22, 2010, 12:26 PM

      Any thoughts?
      This is why I avoid the use of globals at all costs if I can help it at all. It makes code maintenance next to impossible without explicit comments or documentation explaining where these globals are owned and managed.
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        I will drink to that, Jason. This site has some of the worst architecture I’ve ever seen. Even the most trivial of changes requires a massive goose-hunt. It might be ... uh... tolerable?... if I had shell access and could grep for the code, but without that, I’m really stuck.