diff --git a/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php b/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php index 13c5521a1..f9b53305c 100644 --- a/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php +++ b/dist/add-ons/webcachemgr/src/Panel/ControlPanel.php @@ -34,7 +34,7 @@ abstract class ControlPanel /** * @var string */ - const PANEL_API_VERSION = '1.9.7'; + const PANEL_API_VERSION = '1.9.8'; /** * @since 1.9 @@ -816,6 +816,7 @@ public static function meetsMinAPIVerRequirement() public static function checkPanelAPICompatibility( $panelAPIVer ) { $supportedAPIVers = array ( + '1.9.8', '1.9.7', '1.9.6.1', '1.9.6', diff --git a/dist/add-ons/webcachemgr/src/WPCaller.php b/dist/add-ons/webcachemgr/src/WPCaller.php index ba8e13db3..2bbe2c1c7 100644 --- a/dist/add-ons/webcachemgr/src/WPCaller.php +++ b/dist/add-ons/webcachemgr/src/WPCaller.php @@ -1136,6 +1136,85 @@ public function massDashDisable( $extraArgs ) return $ret; } + /** + * Set 'REQUEST_URI' global server and environment variables. + * + * @since 1.9.8 + * + * @param string $key + * @param mixed $val + */ + private function setEnvVar( $key, $val ) + { + $key = 'REQUEST_URI'; + + $_SERVER[$key] = $val; + putenv("{$key}={$val}"); + } + + /** + * Checks if the current WordPress installation is a multisite install and + * does some pre-load setup if so. + * + * Patterns and multisite check logic based on WordPress function + * is_multisite(). + * + * @since 1.9.8 + * + * @return boolean + * @throws LSCMException + */ + private function isMultisite() + { + $isMultiSite = false; + + $pattern1 = '/define\(\s*[\'"]MULTISITE[\'"]\s*,[^;]*;/'; + $pattern2 = '/define\(\s*[\'"]MULTISITE[\'"]\s*,\s*true\s*\)\s*;/'; + $pattern3 = '/define\(\s*[\'"]SUBDOMAIN_INSTALL[\'"]\s*,[^;]*;/'; + $pattern4 = '/define\(\s*[\'"]VHOST[\'"]\s*,[^;]*;/'; + $pattern5 = '/define\(\s*[\'"]SUNRISE[\'"]\s*,[^;]*;/'; + + $config_content = + file_get_contents($this->currInstall->getWpConfigFile()); + + if ( preg_match($pattern1, $config_content, $m1) + && preg_match($pattern2, $m1[0]) ) { + + $isMultiSite = true; + } + elseif ( preg_match($pattern3, $config_content) + || preg_match($pattern4, $config_content) + || preg_match($pattern5, $config_content) ) { + + $isMultiSite = true; + } + + if ( $isMultiSite ) { + + if ( !preg_match('/define\(\s*[\'"]DOMAIN_CURRENT_SITE[\'"]\s*,\s*[\'"](.+)[\'"]\s*\)\s*;/', + $config_content, $m2) ) { + + throw new LSCMException( + 'Cannot find DOMAIN_CURRENT_SITE with MULTISITE defined.'); + } + + $this->currInstall->setServerName($m2[1]); + + if ( !preg_match('/define\(\s*[\'"]PATH_CURRENT_SITE[\'"]\s*,\s*[\'"](.+)[\'"]\s*\)\s*;/', + $config_content, $m3) ) { + + throw new LSCMException( + 'Cannot find PATH_CURRENT_SITE with MULTISITE defined.'); + } + + $this->setEnvVar('REQUEST_URI', $m3[1]); + + define('WP_NETWORK_ADMIN', true); + } + + return $isMultiSite; + } + private function initWp() { /** @@ -1174,36 +1253,10 @@ private function initWp() */ $_SERVER['SCRIPT_FILENAME'] = "{$wpPath}/wp-admin/plugins.php"; - $config_content = - file_get_contents($this->currInstall->getWpConfigFile()); - $uri = ''; - - if ( preg_match('/define\(\s*[\'"]MULTISITE[\'"]\s*,\s*true\s*\)\s*;/', $config_content) ) { - - if ( !preg_match('/define\(\s*[\'"]DOMAIN_CURRENT_SITE[\'"]\s*,\s*[\'"](.+)[\'"]\s*\)\s*;/', - $config_content, $m) ) { - - throw new LSCMException( - 'Cannot find DOMAIN_CURRENT_SITE with MULTISITE defined.'); - } - - $this->currInstall->setServerName($m[1]); - - if ( !preg_match('/define\(\s*[\'"]PATH_CURRENT_SITE[\'"]\s*,\s*[\'"](.+)[\'"]\s*\)\s*;/', - $config_content, $m2) ) { - - throw new LSCMException( - 'Cannot find PATH_CURRENT_SITE with MULTISITE defined.'); - } - - $uri = $m2[1]; - - define('WP_NETWORK_ADMIN', true); + if ( ! $this->isMultisite() ) { + $this->setEnvVar('REQUEST_URI', ''); } - $_SERVER['REQUEST_URI'] = $uri; - putenv("REQUEST_URI={$uri}"); - /** * Set for LSCWP v1.1.5.1+ plugin logic. */ @@ -1212,23 +1265,20 @@ private function initWp() /** * For enable/disable. */ - $_SERVER['DOCUMENT_ROOT'] = $docRoot; - putenv("DOCUMENT_ROOT={$docRoot}"); + $this->setEnvVar('DOCUMENT_ROOT', $docRoot); } - if ( $serverName = $this->currInstall->getServerName() ) { + $serverName = $this->currInstall->getServerName(); - /** - * For security plugins. - */ - $_SERVER['HTTP_HOST'] = $serverName; - putenv("HTTP_HOST={$serverName}"); - } - else { - $_SERVER['HTTP_HOST'] = self::LSCWP_HTTP_HOST_TEST; - putenv('HTTP_HOST=' . self::LSCWP_HTTP_HOST_TEST); + if ( empty($serverName) ) { + $serverName = self::LSCWP_HTTP_HOST_TEST; } + /** + * For security plugins. + */ + $this->setEnvVar('HTTP_HOST', $serverName); + /** * Version specific includes may fail on RC releases. */ diff --git a/src/main/lshttpdmain.cpp b/src/main/lshttpdmain.cpp index 6151da7a0..864b68362 100644 --- a/src/main/lshttpdmain.cpp +++ b/src/main/lshttpdmain.cpp @@ -81,7 +81,7 @@ /*** * Do not change the below format, it will be set correctly while packing the code */ -#define BUILDTIME " (built: Mon Feb 10 19:58:51 UTC 2020)" +#define BUILDTIME " (built: Thu Feb 13 15:07:51 UTC 2020)" #define GlobalServerSessionHooks (LsiApiHooks::getServerSessionHooks()) diff --git a/src/spdy/h2stream.cpp b/src/spdy/h2stream.cpp index 0306176ce..5709b25cd 100644 --- a/src/spdy/h2stream.cpp +++ b/src/spdy/h2stream.cpp @@ -192,7 +192,7 @@ void H2Stream::continueRead() { LS_DBG_L(this, "H2Stream::continueRead()"); setFlag(HIO_FLAG_WANT_READ, 1); - if (m_bufIn.size() > 0) + if (getHandler() && m_bufIn.size() > 0) getHandler()->onReadEx(); } @@ -210,7 +210,7 @@ void H2Stream:: continueWrite() int H2Stream::onTimer() { - if (getState() == HIOS_CONNECTED) + if (getHandler() && getState() == HIOS_CONNECTED) return getHandler()->onTimerEx(); return 0; }