服务器在WordPress上表现不同的问题

时间:2017-06-19 17:47:32

标签: php mysql wordpress iis-7

我们有三台服务器运行我们的主站点。他们使用Window Server 2008 R2,完全修补/更新,以及MySQL 5.5。

第一台和第二台服务器无问题。但是,第三台服务器(物理上与第二台服务器完全相同,但网络有点不同 - 第二台服务器使用的是Meraki设备)存在问题。

我们实现了一个自定义WordPress插件,该插件使用getimagesize()函数(通常在函数前面使用@,但我已删除它以尝试查看错误)。我也禁用了Windows防火墙,只是为了掩盖我的基础。

在第三台服务器上,当加载WordPress后端时,它会在包含以下代码的函数处停止。日志显示没有特定错误,页面错误仅是超过最大时间(目前测试此问题的时间为6分钟)。 php在IIS7上通过FastCGI运行。

任何有关可能导致此问题的见解都将受到赞赏!

这是循环:

$doc = new DOMDocument;
$internalErrors = libxml_use_internal_errors(true);
$doc->loadHTML($contentNoReferences);
libxml_use_internal_errors($internalErrors);
$totalImages = 0;

// Gather image data
foreach($doc->getElementsByTagName('img') as $img)
{
  $fileName = $img->getAttribute('src');

  $ignoreFileDimensions = true;

  // Exclusion cases... CTAs, charts, infographics, graphs, and diagrams (treat _ as -)
  $checkName = str_replace('_', '-', $fileName);
  if(strpos($checkName, '-CTA-') === false &&
    strpos($checkName, '-CTA.') === false &&
    stripos($checkName, '-chart-') === false &&
    stripos($checkName, '-chart.') === false &&
    stripos($checkName, '-diagram-') === false &&
    stripos($checkName, '-diagram.') === false &&
    stripos($checkName, 'infograph') === false &&
    stripos($checkName, 'graph') === false)
  {
    $ignoreFileDimensions = false;
  }

  $totalImages++;
  $lastSlash = strrpos(str_replace('\\', '/', $fileName), '/');
  $fileName = substr($fileName, $lastSlash + 1, strlen($fileName));

  $fileStats = getimagesize(get_option('siteurl') . '/../images/' . $fileName);

  if($ignoreFileDimensions)
  {
    $fileStats[0] = -1;
    $fileStats[1] = -1;
  }

  if($fileStats)
  {
    $images[] = array('filename' => $fileName, 'type' => $fileStats['mime'],
    'width' => $fileStats[0], 'height' => $fileStats[1],
    'size' => remote_file_size(get_option('siteurl') . '/../images/' . $fileName),
    'class' => $img->getAttribute('class'),
    'title' => $img->getAttribute('title'), 'alt' => $img->getAttribute('alt'));
  }
}

1 个答案:

答案 0 :(得分:0)

我发现了这个问题。

我们的CDN快速响应并且没有错误,但是当文件是本地文件时,它们之间会有一些ip查找,每次都会对文件的访问造成延迟。

这最终造成了暂停。

相关问题