Server Connect Changes breaking my dmxConnect.php- too old PHP version

Whenever I make a change to something in Server Connect, Wappler is making a change to dmxConnect.php, uploading to my host, and I can no longer connect to any of the db’s in that connection. I then upload an earlier copy of the dmxConnect.php, upload it, and everything works again, including any changes that I had made.

This started happening less than a week ago, I’m guessing since that last update?

What did I screw up, or am I doing something wrong?

Thank you

What Wappler version are you on and what exactly server connect breaks? Do you get any error?

I’m using 3.8.2

It’s giving a 500 error

It appears to be changing the end of the dmxConnect file from:

if (CONFIG('CORS_ORIGIN') !== FALSE) {
   if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
      $origin = CONFIG('CORS_ORIGIN') ?: '*';
      $methods = CONFIG('CORS_METHODS');
      $allowedHeaders = CONFIG('CORS_ALLOWED_HEADERS');

      header("HTTP/1.1 204 NO CONTENT");
      header("Access-Control-Allow-Origin: $origin");
      header("Access-Control-Allow-Methods: $methods");
      if (CONFIG('CORS_CREDENTIALS') === TRUE) {
         header("Access-Control-Allow-Credentials: true");
      }
      header("Access-Control-Allow-Headers: $allowedHeaders");
      exit();
   } else {
      $origin = CONFIG('CORS_ORIGIN') ?: '*';

      header("Access-Control-Allow-Origin: $origin");
      if (CONFIG('CORS_CREDENTIALS') === TRUE) {
         header("Access-Control-Allow-Credentials: true");
      }
   }
}

to

if (CONFIG('CORS_ORIGIN') !== FALSE) {
   if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
      $origin = CONFIG('CORS_ORIGIN') ?: '*';
      $methods = CONFIG('CORS_METHODS');
      $allowedHeaders = CONFIG('CORS_ALLOWED_HEADERS');
      if ($origin == '*' && isset($_SERVER['HTTP_ORIGIN'])) {
         $origin = $_SERVER['HTTP_ORIGIN'];
      }

      header("HTTP/1.1 204 NO CONTENT");
      header("Access-Control-Allow-Origin: $origin");
      header("Access-Control-Allow-Methods: $methods");
      if (CONFIG('CORS_CREDENTIALS') === TRUE) {
         header("Access-Control-Allow-Credentials: true");
      }
      header("Access-Control-Allow-Headers: $allowedHeaders");
      exit();
   } else {
      $origin = CONFIG('CORS_ORIGIN') ?: '*';
      if ($origin == '*' && isset($_SERVER['HTTP_ORIGIN'])) {
         $origin = $_SERVER['HTTP_ORIGIN'];
      }
      try {
         if (!empty($_SERVER['HTTPS'])) {
            if (version_compare(PHP_VERSION, '7.3.0', '<')) {
               session_set_cookie_params(0, '/; samesite=None', $_SERVER['HTTP_HOST'], TRUE, TRUE);
            } else {
               session_set_cookie_params([
                  'samesite' => 'None',
                  'httponly' => TRUE,
                  'secure' => TRUE
               ]);
            }
         }
      } catch (\Exception $e) {
         // ignore
      }
 
      header("Access-Control-Allow-Origin: $origin");
      if (CONFIG('CORS_CREDENTIALS') === TRUE) {
         header("Access-Control-Allow-Credentials: true");
      }
   }
}

wow, I formatted that reply easier to read than it came across… hehe

So what’s the exact error 500 message saying?

http error 500

I’m not experienced with the dev tools, but it looks like failed to load sourcemap?

riverraisincentre.org

riverraisincentre.org/Rentals/Studios/StudioCalendar-User.php
does’t load the events from the database

riverraisincentre.org](https://riverraisincentre.org/Admin/index.php
doesn’t let me try to log in.

No, this is not an error, so just ignore it.
Follow this article to see the exact error returned by your server action:

Naturally it isn’t too clear…

Whichever page I go to that calls for a database, it shows:

fetch.js:255 GET https://riverraisincentre.org/dmxConnect/api/Studios/studio_list.php? 500

The only difference is the page link.

Can you post the PHP error that you are getting. Also please mention the PHP version that you are running on your server.

Hello,

My host was running PHP version 5.3. I just upgraded it to 7.0. I didn’t see a PHP error.

This morning my host started showing a ‘502 Bad Gateway’ error. I contacted my provider and they are looking into it. I guess I’m shutdown for the time being.

Mike

My server host fixed my site, I’m not sure what they did, but everything is working now. I’m assuming that upgrading php also helped. Thank you for your time and efforts!

2 Likes

Tut-tut :cold_sweat: