Skip to content

Commit

Permalink
Changes to fix errors when deactivating plugin via Command Line; see: w…
Browse files Browse the repository at this point in the history
  • Loading branch information
renzms committed May 25, 2016
1 parent 6dadb72 commit 1586257
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/includes/traits/Ac/BrowserUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function maybeStopBrowserCaching()
return $this->sendNoCacheHeaders(); // Disallow.
} // Else, allow client-side caching; because `ABC` is a true-ish value.
// ↑ Note that exclusion patterns are ignored in this case, in favor of `ABC`.
} elseif (COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS && preg_match(COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS, $_SERVER['REQUEST_URI'])) {
} elseif (COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS && (empty($_SERVER['REQUEST_URI']) || preg_match(COMET_CACHE_EXCLUDE_CLIENT_SIDE_URIS, $_SERVER['REQUEST_URI']))) {
return $this->sendNoCacheHeaders(); // Disallow.
}
return; // Allow browser caching; default behavior in this mode.
Expand Down
2 changes: 1 addition & 1 deletion src/includes/traits/Plugin/DirUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function wpHomePath()
{
$home = set_url_scheme(get_option('home'), 'http');
$siteurl = set_url_scheme(get_option('siteurl'), 'http');
if (!empty($home) && 0 !== strcasecmp($home, $siteurl)) {
if (!empty($home) && 0 !== strcasecmp($home, $siteurl) && !empty($_SERVER['SCRIPT_FILENAME'])) {
$wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */
$pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home));
$home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
Expand Down
2 changes: 1 addition & 1 deletion src/includes/traits/Plugin/NoticeUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function allAdminNotices()
}
# Current URI matches a limited scope/context for this notice?
if ($_notice['only_on_uris'] && !@preg_match($_notice['only_on_uris'], $_SERVER['REQUEST_URI'])) {
if ($_notice['only_on_uris'] && (empty($_SERVER['REQUEST_URI']) || !@preg_match($_notice['only_on_uris'], $_SERVER['REQUEST_URI']))) {
continue; // Not in the right context at the moment; i.e., does not regex.
}
# If persistent, allow a site owner to dismiss.
Expand Down
6 changes: 3 additions & 3 deletions src/includes/traits/Shared/TokenUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public function hostToken($dashify = false, $consider_domain_mapping = false, $c
$token = ''; // Initialize token value.

if (!is_multisite() || $this->isAdvancedCache()) {
$token = (string) $_SERVER['HTTP_HOST'];
$token = !empty($_SERVER['HTTP_HOST']) ? (string) $_SERVER['HTTP_HOST'] : '';
} elseif ($consider_domain_mapping && $this->canConsiderDomainMapping()) {
if (($consider_domain_mapping_domain = trim((string) $consider_domain_mapping_domain))) {
$token = $consider_domain_mapping_domain;
} elseif ($this->isDomainMapping()) {
$token = (string) $_SERVER['HTTP_HOST'];
$token = !empty($_SERVER['HTTP_HOST']) ? (string) $_SERVER['HTTP_HOST'] : '';
} else { // For the current blog ID.
$token = $this->domainMappingUrlFilter($this->currentUrl());
$token = $this->parseUrl($token, PHP_URL_HOST);
}
}
if (!$token) { // Use default?
$token = (string) $_SERVER['HTTP_HOST'];
$token = !empty($_SERVER['HTTP_HOST']) ? (string) $_SERVER['HTTP_HOST'] : '';
}
if ($token) { // Have token?
$token = strtolower($token);
Expand Down
5 changes: 4 additions & 1 deletion src/includes/traits/Shared/UrlUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public function isSsl()
*/
public function currentUrl()
{
return ($this->isSsl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (empty($_SERVER['HTTP_HOST']) || empty($_SERVER['REQUEST_URI'])) {
return ''; // Not possible.
}
return ($this->isSsl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
}

0 comments on commit 1586257

Please sign in to comment.