Errors after upgrading from version 2.xx to 3.61

8 posts by 2 authors in: Forums > CMS Builder
Last Post: October 12, 2023   (RSS)

By glennp - October 11, 2023

Hello,

After upgrading I'm getting the following errors when saving any record (the record does save correctly however the error appears in a pop-up).

1. PHP Fatal error: Uncaught Error: Call to undefined function escapeshellarg() in /PATH-ON-SERVER/DOMAIN/cms-admin/lib/file_functions.php:331\nStack trace:\n#0 /PATH-ON-SERVER/DOMAIN/cms-admin/lib/serverInfo_functions.php(153): uber_file_get_contents()\n#1 /PATH-ON-SERVER/DOMAIN/cms-admin/lib/serverInfo_functions.php(24): serverInfo_operatingSystem()\n#2 [internal function]: updateServerChangeLog()\n#3 {main}\n thrown in /PATH-ON-SERVER/DOMAIN/cms-admin/lib/file_functions.php on line 331', referer: https:/DOMAIN/cms-admin/admin.php?menu=_error_log

This is from the log:

#1230576 - Fatal Error: Uncaught Error: Call to undefined function escapeshellarg()
/PATH-ON-SERVER/DOMAIN/cms-admin/lib/file_functions.php on line 331
http://DOMAIN/cms-admin/admin.php?menu=admin&action=general

Other issues:

The "General Settings" page has no styling and no button to save changes. At the bottom of the page are the same errors mentioned above.

On the "Security Settings" page checking the box "require https" displays "Require HTTPS: You must be logged in with a secure HTTPS url to set this option!" when clicking "save". I am logged in with HTTPS.

Thanks!

Glenn

By Dave - October 11, 2023

Hi Glenn, 

It looks like that first error is occurring because your server has disabled some of the PHP functions.  Let's see if we can work around that one first and then see what's next.

If you're comfortable editing PHP code here's how to apply a patch: 

  • Open /lib/file_functions.php
  • Search for:  is_open_basedir_restrictions
  • Add the code in red: 

 // if no open basedir restrictions, return value from file_get_contents
$is_open_basedir_restrictions = ini_get('open_basedir') && !@file_exists("/"); // if root doesn't exist then open_basedir in effect. In the future, we can check if target filepath matches open_basedir
if (!$is_open_basedir_restrictions) { return $r; }

// Fail here if shell commands aren't available
if (!function_exists('escapeshellarg')) { return false; }

// otherwise, try Windows shell commands
if (isWindows()) {
$filepath = str_replace("/", "\\", $filepath); // use windows slashes
$command = 'type ' .escapeshellarg($filepath);
$response = shellCommand($command); // for debugging add: 2>&1
return $response;
}

Let me know if that resolves the first issue and then we can go from there.

Dave Edis - Senior Developer
interactivetools.com

By glennp - October 11, 2023

Hi Dave,

Thanks for the info! That resolved the error when saving records and the general settings page issue.

The only other thing that I'm aware of is the "require https" issue.

Glenn

By Dave - October 11, 2023

Hi Glenn, 

Okay great, glad that the first issue is resolved.

For the HTTPS issue, the server may be behind a load balancer or some other configuration where the CMS can't detect HTTPS.

Can you send me your _SERVER variables? Here's how:

  • Make sure you're connected via HTTPS
  • Go to Admin > General > Server Info: /admin.php?menu=admin&action=general#server-info
  • Beside the PHP Version, click on the phpinfo link
  • Search for _SERVER and copy and paste all those values into this post
  • Feel free to remove any sensitive paths or domains from the content

Once we see those we might be able to suggest a solution.

Dave Edis - Senior Developer
interactivetools.com

By glennp - October 11, 2023

Hi Dave,

Here's the info (edited)

$_SERVER['USER'] USER
$_SERVER['HOME'] /PATH/
$_SERVER['SCRIPT_NAME'] /cms-admin/admin.php
$_SERVER['REQUEST_URI'] /cms-admin/admin.php?menu=admin&action=phpinfo
$_SERVER['QUERY_STRING'] menu=admin&action=phpinfo
$_SERVER['REQUEST_METHOD'] GET
$_SERVER['SERVER_PROTOCOL'] HTTP/1.1
$_SERVER['GATEWAY_INTERFACE'] CGI/1.1
$_SERVER['REMOTE_PORT'] 64288
$_SERVER['SCRIPT_FILENAME'] /PATH/DONMAIN/cms-admin/admin.php
$_SERVER['SERVER_ADMIN'] webmaster@domain.com
$_SERVER['CONTEXT_DOCUMENT_ROOT'] /PATH/DONMAIN
$_SERVER['CONTEXT_PREFIX'] no value
$_SERVER['REQUEST_SCHEME'] http
$_SERVER['DOCUMENT_ROOT'] /PATH/DONMAIN
$_SERVER['REMOTE_ADDR'] xx.xx.xx.xx
$_SERVER['SERVER_PORT'] 80
$_SERVER['SERVER_ADDR'] xx.xx.xx.xx
$_SERVER['SERVER_NAME'] www.domain.com
$_SERVER['SERVER_SOFTWARE'] Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k
$_SERVER['SERVER_SIGNATURE'] no value
$_SERVER['PATH'] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
$_SERVER['HTTP_COOKIE'] xxxxxxxxxxx;
nmstat=a4d01b68-8626-b378-c03f-cdbf4b80d049; smcx_427613167_last_shown_at=1696085386790; smcx_453140645_last_shown_at=1696176603598; smcx_453140583_last_shown_at=1696176623939; _gid=GA1.2.841994204.1696895672; cms_19112_PHPSESSID=c5d6ue92uempvp71oa2rui1420; _ga=GA1.2.1819297711.1693914079; _ga_7NNXQDVPEP=GS1.1.1697058663.48.1.1697060391.0.0.0; cms_19112_loginsession=9RzM2EzNwcTO2EjOiM3clN2YBR3chxmIsICZxETZ4kzN4ATZ1YjNlZWZ4QzNkZzM4QTYxgDOlRGNwUGZjZDM4UzYkETYoNHJiojIoNXYIRmcvd3czFGciwiIulWbkFmI6ISZtFmbyV2c1Jye
$_SERVER['HTTP_ACCEPT_LANGUAGE'] en-US,en;q=0.9
$_SERVER['HTTP_ACCEPT_ENCODING'] gzip, deflate, br
$_SERVER['HTTP_REFERER'] https://www.domain.com/cms-admin/admin.php?menu=admin&action=general
$_SERVER['HTTP_SEC_FETCH_DEST'] document
$_SERVER['HTTP_SEC_FETCH_USER'] ?1
$_SERVER['HTTP_SEC_FETCH_MODE'] navigate
$_SERVER['HTTP_SEC_FETCH_SITE'] same-origin
$_SERVER['HTTP_ACCEPT'] text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
$_SERVER['HTTP_USER_AGENT'] Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
$_SERVER['HTTP_UPGRADE_INSECURE_REQUESTS'] 1
$_SERVER['HTTP_SEC_CH_UA_PLATFORM'] "Windows"
$_SERVER['HTTP_SEC_CH_UA_MOBILE'] ?0
$_SERVER['HTTP_SEC_CH_UA'] "Google Chrome";v="117", "Not;A=Brand";v="8", "Chromium";v="117"
$_SERVER['HTTP_CONNECTION'] keep-alive
$_SERVER['HTTP_HOST'] www.domain.com
$_SERVER['proxy-nokeepalive'] 1
$_SERVER['HTTP_PROXY_PORT'] 8080
$_SERVER['HTTP_PROXY_HOST'] xxxxxxxxxx
$_SERVER['SCRIPT_URI'] http://www.domain.com/cms-admin/admin.php
$_SERVER['SCRIPT_URL'] /cms-admin/admin.php
$_SERVER['UNIQUE_ID'] ZSdCO3knQ2F4oklMSMTcSAAAAJA
$_SERVER['on'] 1
$_SERVER['HTTPS'] 1
$_SERVER['FCGI_ROLE'] RESPONDER
$_SERVER['PHP_SELF'] /cms-admin/admin.php
$_SERVER['REQUEST_TIME_FLOAT'] 1697071675.102
$_SERVER['REQUEST_TIME'] 1697071675
$_SERVER['PHP_SELF_ORIGINAL'] /cms-admin/admin.php

By Dave - October 11, 2023

Hi Glenn, 

Hmm, interesting.  We haven't seen HTTPS = 1 before but we can add a check for it so that server is supported.

Here's how to patch that (and we'll include this in the next release): 

  • Open /lib/http_functions.php
  • Search for $_SERVER['HTTPS']
  • Replace this:
function isHTTPS(): bool {
  if (isset($_SERVER['HTTPS'])       && $_SERVER['HTTPS']       == 'on') { return true; }
  • With this: 
function isHTTPS(): bool {
  if (in_array($_SERVER['HTTPS'] ?? '', ['on', 1])) { return true; }

Let me know if that works for you!

Dave Edis - Senior Developer
interactivetools.com

By glennp - October 12, 2023

Hi Dave,

That worked! I'll let you know if I discover anything else.

As always, thanks for your help!

Glenn