We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31337
    • 258 Posts
    I’m looking at index.php in the install dir, specifically at the section of lines starting at line #433 which looks like this:
    // config.inc.php writable?
        echo "<p>Checking if <span class='mono'>manager/includes/config.inc.php</span> is writable: ";
        $isWriteable = is_writable("../manager/includes/config.inc.php");
        if(!file_exists("../manager/includes/config.inc.php")) {
          // make an attempt to create the file
          @$hnd=fopen("../manager/includes/config.inc.php", 'w');
          @fwrite($hnd,"<?php //MODx configuration file ?>");
          @fclose($hnd);
          $isWriteable = file_exists("../manager/includes/config.inc.php");
          @unlink("../manager/includes/config.inc.php");
        }
        if(!$isWriteable) {
          echo "<span class='notok'>Failed!</span></p><p><strong>For new Linux/Unix installs, please create a blank file named <span class='mono'>config.inc.php</span> in the <span class='mono'>manager/includes/</span> directory with file permissions set to 777.</strong></p>";
          $errors += 1;
        } else {
          echo "<span class='ok'>OK!</span></p>";
        }
    


    That logic seems backwards to me. Shouldn’t it look something like this?:
    // config.inc.php writable?
        echo "<p>Checking if <span class='mono'>manager/includes/config.inc.php</span> is writable: "; 
        if(!file_exists("../manager/includes/config.inc.php")) {
          // make an attempt to create the file
          @$hnd=fopen("../manager/includes/config.inc.php", 'w');
          @fwrite($hnd,"<?php //MODx configuration file ?>");
          @fclose($hnd);
        }
        $isWriteable = is_writable("../manager/includes/config.inc.php");
        if(!$isWriteable) {
          echo "<span class='notok'>Failed!</span></p><p><strong>For new Linux/Unix installs, please create a blank file named <span class='mono'>config.inc.php</span> in the <span class='mono'>manager/includes/</span> directory with file permissions set to 777.</strong></p>";
          $errors += 1;
        } else {
          echo "<span class='ok'>OK!</span></p>";
        }
    


    In other words, we check if the file is there, and if not we create it and leave it alone (why are we unlinking it to start with?) and only then check for permissions and such. BTW, I also think there should be better error handling in there to deal with permission problems and such but that’s a different issue.

    Anyway, am I missing something in why the current code is structured the way it is?
      • 25663 MODX Staff
      • 12,272 Posts
      The installer has not been looked at in a long time, so there’s a chance that the logic could use some revising.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 1764
        • 680 Posts
        Doesn’t make sense to me either. I’d say change it. I’ve never had it successfully create a config.inc.php file for me, now I know why.

        The installer does need an upgrade, definitely. Snippet/plugin/module configuration upgrades don’t really work and do we have any multi-lingual capabilities built into the installer? The organization of it seems a bit weird too.

        When we do get around to upgrading the installer I think we should do it with the resource installer in mind. In the backend I think the installer should be two separate parts, the core installer and the resource installer. The resource installer could use the same code as the resource installer built into the manager, just a different interface.