We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28215
    • 4,149 Posts
    Quote from: greno at Oct 14, 2009, 09:50 AM

    My memory_limit was set at 8M! And timeout was 30.
    If we need to have 128M then why don’t you just set the test as: if <128M set to 128M?

    We actually do; however, PHP’s memory_limit function seems to not always be correct in calculating the number, and it definitely doesn’t always work to set the memory_limit at runtime, as certain server configurations prevent one from doing so.
      shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
      • 11318
      • 13 Posts
      Quote from: splittingred at Oct 14, 2009, 10:02 AM


      We actually do; however, PHP’s memory_limit function seems to not always be correct in calculating the number, and it definitely doesn’t always work to set the memory_limit at runtime, as certain server configurations prevent one from doing so.

      If it fails to set the settings do you warn the user that it failed to set? All I saw was a blank page but no warnings.

      Regards,
      Gerry Reno
        • 28215
        • 4,149 Posts
        Quote from: greno at Oct 14, 2009, 10:11 AM

        If it fails to set the settings do you warn the user that it failed to set? All I saw was a blank page but no warnings.

        Yes, the code is here:

        $ml = ini_get('memory_limit');
        $bytes = $this->return_bytes($ml);
        
        if ($bytes < 67108864) { /* 32M = 33554432, 64M = 67108864 */
            $success = @ini_set('memory_limit','128M');
            $success = $success !== false ? true : false;
        } else {
            $success = true;
        }
        
        $this->results['memory_limit']['msg'] = '<p>'.$this->install->lexicon['test_memory_limit'].' ';
        if ($success) {
               $this->results['memory_limit']['msg'] .= '<span class="ok">'.$this->install->lexicon['ok'].'</span></p>';
               $this->results['memory_limit']['class'] = 'testPassed';
        } else {
               $s = '<span class="notok">'.$this->install->lexicon['failed'].'</span>';
               $s .= '<div class="notes"><p>'.sprintf($this->install->lexicon['test_memory_limit_fail'],$ml).'</p></div>';
               $s .= '</p>';
               $this->results['memory_limit']['msg'] .= $s;
               $this->results['memory_limit']['class'] = 'testFailed';
        }
        
        // ...
        
        function return_bytes($val) {
                $val = trim($val);
                $num = intval(substr($val,0,strlen($val)-1));
                $last = strtolower(substr($val,strlen($val),1));
                switch ($last) {
                    case 'g':
                        $num *= 1024;
                    case 'm':
                        $num *= 1024;
                    case 'k':
                        $num *= 1024;
                }
                return $num;
            }
        


        So if it is not showing a warning for you, then your php configuration is set up so that one of two things is happening:


        • ini_get(’memory_limit’) is not returning an accurate value
        • ini_set(’memory_limit’) is returning true when it isn’t really working
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 11318
          • 13 Posts
          What I found after I got nothing but the blank page was that the install had installed the tables and then apparently failed. So wouldn’t it be better if the very first thing was to try to set the ini settings and if they fail to stop the install at that point without loading any tables? That way the only thing the user would have to do would be to set the ini settings and rerun setup. Rather than having to also go into mysql and drop and recreate the database.

          Regards,
          Gerry Reno
            • 11318
            • 13 Posts
            Also, how do you get the new ini settings to take effect. I usually have to restart Apache to get new ini settings to take effect?

            Regards,
            Gerry Reno
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: greno at Oct 14, 2009, 10:22 AM

              What I found after I got nothing but the blank page was that the install had installed the tables and then apparently failed. So wouldn’t it be better if the very first thing was to try to set the ini settings and if they fail to stop the install at that point without loading any tables? That way the only thing the user would have to do would be to set the ini settings and rerun setup. Rather than having to also go into mysql and drop and recreate the database.
              There are memory_limit warnings in the setup; not sure why yours didn’t prevent installation. Perhaps your configuration is not reporting the proper memory_limit?

              Quote from: greno at Oct 14, 2009, 10:36 AM

              Also, how do you get the new ini settings to take effect. I usually have to restart Apache to get new ini settings to take effect?
              Yep, you have to restart Apache.
                • 11318
                • 13 Posts
                Quote from: OpenGeek at Oct 14, 2009, 12:23 PM

                Yep, you have to restart Apache.

                I guess my point was that if those memory settings are needed for a successful install then they cannot be set BY the install. They have to be set before the install. Or the install has to stop and tell the user to restart Apache and rerun the setup. I didn’t see any of this happening. Does the install log what it has detected as far as memory_limit?

                Regards,
                Gerry Reno
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: greno at Oct 14, 2009, 12:32 PM

                  I guess my point was that if those memory settings are needed for a successful install then they cannot be set BY the install. They have to be set before the install. Or the install has to stop and tell the user to restart Apache and rerun the setup. I didn’t see any of this happening. Does the install log what it has detected as far as memory_limit?
                  The hope is that folks will read the server requirements before even downloading MODx Revolution.

                  No, it does not log what it detects as memory_limit, but displays warnings if ini_get(’memory_limit’) does not report a value that is sufficient to support installation.
                    • 11318
                    • 13 Posts
                    Quote from: OpenGeek at Oct 14, 2009, 12:37 PM

                    Quote from: greno at Oct 14, 2009, 12:32 PM

                    I guess my point was that if those memory settings are needed for a successful install then they cannot be set BY the install. They have to be set before the install. Or the install has to stop and tell the user to restart Apache and rerun the setup. I didn’t see any of this happening. Does the install log what it has detected as far as memory_limit?
                    The hope is that folks will read the server requirements before even downloading MODx Revolution.

                    No, it does not log what it detects as memory_limit, but displays warnings if ini_get(’memory_limit’) does not report a value that is sufficient to support installation.

                    It should not be difficult for the install to stop if it has to reset the ini settings and tell the user to restart Apache and then rerun the install. That would prevent a lot of user installation issues. I agree that people should read the documentation prior to downloading the software but as we all know 96.54321% of all users don’t do that. smiley

                    Regards,
                    Gerry Reno
                      • 22303 MODX Staff
                      • 10,725 Posts
                      Quote from: greno at Oct 14, 2009, 12:42 PM

                      It should not be difficult for the install to stop if it has to reset the ini settings and tell the user to restart Apache and then rerun the install. That would prevent a lot of user installation issues. I agree that people should read the documentation prior to downloading the software but as we all know 96.54321% of all users don’t do that. smiley
                      I most cases, MODx cannot set PHP ini settings like this, these can only be set in server configurations. In cases where it can change them on the fly it does and there is no Apache restart required.