isArchivePhpTriggered() public static method

Helpful for error handling: directly throw error without HTML (eg. when DB is down).
public static isArchivePhpTriggered ( ) : boolean
return boolean
Ejemplo n.º 1
0
 public function getSelectQueryString(SegmentExpression $segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit)
 {
     $result = parent::getSelectQueryString($segmentExpression, $select, $from, $where, $bind, $groupBy, $orderBy, $limit);
     $prefixParts = array();
     if (SettingsServer::isArchivePhpTriggered()) {
         $prefixParts[] = 'trigger = CronArchive';
     }
     $idSegments = $this->getSegmentIdOfExpression($segmentExpression);
     if (!empty($idSegments)) {
         $prefixParts[] = "idSegments = [" . implode(', ', $idSegments) . "]";
     }
     if (!empty($prefixParts)) {
         $result['sql'] = "/* " . implode(', ', $prefixParts) . " */\n" . $result['sql'];
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Returns the URL to this Piwik instance, eg. **http://demo.piwik.org/** or **http://example.org/piwik/**.
  *
  * @return string
  * @api
  */
 public static function getPiwikUrl()
 {
     $url = Option::get(self::OPTION_PIWIK_URL);
     $isPiwikCoreDispatching = defined('PIWIK_ENABLE_DISPATCH') && PIWIK_ENABLE_DISPATCH;
     if (Common::isPhpCliMode() || SettingsServer::isArchivePhpTriggered() || !$isPiwikCoreDispatching) {
         return $url;
     }
     $currentUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName());
     // when script is called from /misc/cron/archive.php, Piwik URL is /index.php
     $currentUrl = str_replace("/misc/cron", "", $currentUrl);
     if (empty($url) || $currentUrl != $url) {
         if (strlen($currentUrl) >= strlen('http://a/')) {
             self::overwritePiwikUrl($currentUrl);
         }
         $url = $currentUrl;
     }
     if (ProxyHttp::isHttps()) {
         $url = str_replace("http://", "https://", $url);
     }
     return $url;
 }
 public static function shouldRethrowException()
 {
     // If we are in no dispatch mode, eg. a script reusing Piwik libs,
     // then we should return the exception directly, rather than trigger the event "bad config file"
     // which load the HTML page of the installer with the error.
     return defined('PIWIK_ENABLE_DISPATCH') && !PIWIK_ENABLE_DISPATCH || Common::isPhpCliMode() || SettingsServer::isArchivePhpTriggered();
 }
Ejemplo n.º 4
0
 public static function isRequestAuthorizedToArchive()
 {
     return Rules::isBrowserTriggerEnabled() || SettingsServer::isArchivePhpTriggered();
 }
Ejemplo n.º 5
0
 /**
  * Returns the URL to this Piwik instance, eg. **http://demo.piwik.org/** or **http://example.org/piwik/**.
  *
  * @return string
  * @api
  */
 public static function getPiwikUrl()
 {
     // Only set in tests
     if (self::$piwikUrlCache !== null) {
         return self::$piwikUrlCache;
     }
     $key = 'piwikUrl';
     $url = Option::get($key);
     if (Common::isPhpCliMode() || SettingsServer::isArchivePhpTriggered() || defined('PIWIK_MODE_ARCHIVE')) {
         return $url;
     }
     $currentUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName());
     if (empty($url) || $currentUrl != $url) {
         if (strlen($currentUrl) >= strlen('http://a/')) {
             Option::set($key, $currentUrl, $autoLoad = true);
         }
         $url = $currentUrl;
     }
     return $url;
 }
Ejemplo n.º 6
0
<?php

// Good old test proxy endpoints have some commons
if (!defined('PIWIK_INCLUDE_PATH')) {
    define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__)) . '/../../../');
}
if (!defined('PIWIK_USER_PATH')) {
    define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH);
}
require_once file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php') ? PIWIK_INCLUDE_PATH . '/vendor/autoload.php' : PIWIK_INCLUDE_PATH . '/../../autoload.php';
// Piwik is installed as a dependency
require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php';
require_once PIWIK_INCLUDE_PATH . '/core/Piwik.php';
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
require_once PIWIK_INCLUDE_PATH . '/tests/PHPUnit/TestingEnvironment.php';
if (file_exists(PIWIK_INCLUDE_PATH . '/vendor/autoload.php')) {
    $vendorDirectory = PIWIK_INCLUDE_PATH . '/vendor';
} else {
    $vendorDirectory = PIWIK_INCLUDE_PATH . '/../..';
}
require_once $vendorDirectory . '/autoload.php';
require_once $vendorDirectory . '/mustangostang/spyc/Spyc.php';
require_once $vendorDirectory . '/piwik/device-detector/DeviceDetector.php';
\Piwik\SettingsServer::setMaxExecutionTime(0);
// Make sure Data processed in cron core:archive command is not being purged instantly (useful for: Integration/ArchiveCronTest)
if (\Piwik\SettingsServer::isArchivePhpTriggered()) {
    \Piwik\ArchiveProcessor\Rules::disablePurgeOutdatedArchives();
}
Ejemplo n.º 7
0
 protected static function isRequestAuthorizedToArchive()
 {
     return !self::$archivingDisabledByTests && (Rules::isBrowserTriggerEnabled() || Common::isPhpCliMode() || Piwik::isUserIsSuperUser() && SettingsServer::isArchivePhpTriggered());
 }