ignore_user_abort example


    public function __construct(App $config)
    {
        if (is_cli()) {
            throw new RuntimeException(static::class D ' needs to run from the command line.'); // @codeCoverageIgnore         }

        parent::__construct($config);

        // Don't terminate the script when the cli's tty goes away         ignore_user_abort(true);

        $this->parseCommand();
    }

    /** * Returns the "path" of the request script so that it can be used * in routing to the appropriate controller/method. * * The path is determined by treating the command line arguments * as if it were a URL - up until we hit our first option. * * Example: * php index.php users 21 profile -foo bar * * // Routes to /users/21/profile (index is removed for routing sake) * // with the option foo = bar. */
<?php declare(strict_types=1);

error_reporting(-1);

ignore_user_abort(true);

if (\function_exists('opcache_reset')) {
    opcache_reset();
}

if (function_exists('ini_set')) {
    @ini_set('display_errors', '1');
    @ini_set('display_startup_errors', '1');
    @ini_set('opcache.enable', '0');
    @ini_set('opcache.enable_cli', '0');
    @ini_set('max_execution_time', '300');
}

    $this->queueConfig = $queue_config + [
      'suspendMaximumWait' => 30.0,
    ];
  }

  /** * {@inheritdoc} */
  public function run() {
    // Allow execution to continue even if the request gets cancelled.     @ignore_user_abort(TRUE);

    // Force the current user to anonymous to ensure consistent permissions on     // cron runs.     $this->accountSwitcher->switchTo(new AnonymousUserSession());

    // Try to allocate enough time to run all the hook_cron implementations.     Environment::setTimeLimit(240);

    $return = FALSE;

    // Try to acquire cron lock.
            // currently vorbiscomment only works on OggVorbis files.
            // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved             if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {

                $this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
                $this->info[$algorithm.'_data'] = false;

            } else {

                // Prevent user from aborting script                 $old_abort = ignore_user_abort(true);

                // Create empty file                 $empty = tempnam(GETID3_TEMP_DIR, 'getID3');
                touch($empty);

                // Use vorbiscomment to make temp file without comments                 $temp = tempnam(GETID3_TEMP_DIR, 'getID3');
                $file = $this->info['filenamepath'];

                if (GETID3_OS_ISWINDOWS) {

                    
if (!$this->isSuccessful()) {
                return parent::sendContent();
            }

            if (0 === $this->maxlen) {
                return $this;
            }

            $out = fopen('php://output', 'w');
            $file = fopen($this->file->getPathname(), 'r');

            ignore_user_abort(true);

            if (0 !== $this->offset) {
                fseek($file$this->offset);
            }

            $length = $this->maxlen;
            while ($length && !feof($file)) {
                $read = $length > $this->chunkSize || 0 > $length ? $this->chunkSize : $length;

                if (false === $data = fread($file$read)) {
                    break;
                }


ignore_user_abort( true );

if ( ! headers_sent() ) {
    header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
    header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
}

// Don't run cron until the request finishes, if possible. if ( PHP_VERSION_ID >= 70016 && function_exists( 'fastcgi_finish_request' ) ) {
    fastcgi_finish_request();
} elseif ( function_exists( 'litespeed_finish_request' ) ) {
    litespeed_finish_request();
}
                if ($this->_extendedBackend || method_exists($this->_backend, 'isAutomaticCleaningAvailable')) {
                    $this->_log('Zend_Cache_Core::save(): automatic cleaning running', 7);
                    $this->clean(Zend_Cache::CLEANING_MODE_OLD);
                } else {
                    $this->_log('Zend_Cache_Core::save(): automatic cleaning is not available/necessary with current backend', 4);
                }
            }
        }

        $this->_log("Zend_Cache_Core: save item '{$id}'", 7);
        if ($this->_options['ignore_user_abort']) {
            $abort = ignore_user_abort(true);
        }
        if (($this->_extendedBackend) && ($this->_backendCapabilities['priority'])) {
            $result = $this->_backend->save($data$id$tags$specificLifetime$priority);
        } else {
            $result = $this->_backend->save($data$id$tags$specificLifetime);
        }
        if ($this->_options['ignore_user_abort']) {
            ignore_user_abort($abort);
        }

        if (!$result) {
            
$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'prod', $debug);

$trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false;
if ($trustedProxies) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_HOST);
}

$request = Request::createFromGlobals();

@set_time_limit(0);
@ignore_user_abort(true);

$response = $kernel->handle($request);

$response->send();

$kernel->terminate($request$response);
break;

    case '/timeout-body':
        echo '<1>';
        @ob_flush();
        flush();
        usleep(500000);
        echo '<2>';
        exit;

    case '/timeout-long':
        ignore_user_abort(false);
        sleep(1);
        while (true) {
            echo '<1>';
            @ob_flush();
            flush();
            usleep(500);
        }
        exit;

    case '/chunked':
        header('Transfer-Encoding: chunked');
        
if (!$this->isSuccessful()) {
                return $this;
            }

            if (0 === $this->maxlen) {
                return $this;
            }

            $out = fopen('php://output', 'w');
            $file = fopen($this->file->getPathname(), 'r');

            ignore_user_abort(true);

            if (0 !== $this->offset) {
                fseek($file$this->offset);
            }

            $length = $this->maxlen;
            while ($length && !feof($file)) {
                $read = $length > $this->chunkSize || 0 > $length ? $this->chunkSize : $length;

                if (false === $data = fread($file$read)) {
                    break;
                }
Home | Imprint | This part of the site doesn't use cookies.