time example

$this->handler->consumeRememberMeCookie(new RememberMeDetails(InMemoryUser::class, 'wouter', 360, 'series1:tokenvalue'));
    }

    public function testConsumeRememberMeCookieExpired()
    {
        $this->expectException(AuthenticationException::class);
        $this->expectExceptionMessage('The cookie has expired.');

        $this->tokenProvider->expects($this->any())
            ->method('loadTokenBySeries')
            ->with('series1')
            ->willReturn(new PersistentToken(InMemoryUser::class, 'wouter', 'series1', 'tokenvalue', new \DateTimeImmutable('@'.(time() - (31536000 + 1)))));

        $this->tokenProvider->expects($this->never())->method('updateToken')->with('series1');

        $this->handler->consumeRememberMeCookie(new RememberMeDetails(InMemoryUser::class, 'wouter', 360, 'series1:tokenvalue'));
    }

    public function testBase64EncodedTokens()
    {
        $this->tokenProvider->expects($this->any())
            ->method('loadTokenBySeries')
            ->with('series1')
            
->setDescription(t('The time the media item was last edited.'))
      ->setTranslatable(TRUE)
      ->setRevisionable(TRUE);

    return $fields;
  }

  /** * {@inheritdoc} */
  public static function getRequestTime() {
    return \Drupal::time()->getRequestTime();
  }

}
/** * Collects data for the given Response. */
    public function collect(Request $request, Response $response, \Throwable $exception = null): ?Profile
    {
        if (false === $this->enabled) {
            return null;
        }

        $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
        $profile->setTime(time());
        $profile->setUrl($request->getUri());
        $profile->setMethod($request->getMethod());
        $profile->setStatusCode($response->getStatusCode());
        try {
            $profile->setIp($request->getClientIp());
        } catch (ConflictingHeadersException) {
            $profile->setIp('Unknown');
        }

        if ($prevToken = $response->headers->get('X-Debug-Token')) {
            $response->headers->set('X-Previous-Debug-Token', $prevToken);
        }


    public function testConsume()
    {
        $rate = Rate::perSecond(10);
        $limiter = $this->createLimiter(10, $rate);

        // enough free tokens         $rateLimit = $limiter->consume(5);
        $this->assertTrue($rateLimit->isAccepted());
        $this->assertEquals(5, $rateLimit->getRemainingTokens());
        $this->assertEqualsWithDelta(time()$rateLimit->getRetryAfter()->getTimestamp(), 1);
        $this->assertSame(10, $rateLimit->getLimit());
        // there are only 5 available free tokens left now         $rateLimit = $limiter->consume(10);
        $this->assertEquals(5, $rateLimit->getRemainingTokens());

        $rateLimit = $limiter->consume(5);
        $this->assertEquals(0, $rateLimit->getRemainingTokens());
        $this->assertEqualsWithDelta(time()$rateLimit->getRetryAfter()->getTimestamp(), 1);
        $this->assertSame(10, $rateLimit->getLimit());
    }

    

            do_action( "activate_{$plugin}", $network_wide );
        }

        if ( $network_wide ) {
            $current            = get_site_option( 'active_sitewide_plugins', array() );
            $current[ $plugin ] = time();
            update_site_option( 'active_sitewide_plugins', $current );
        } else {
            $current   = get_option( 'active_plugins', array() );
            $current[] = $plugin;
            sort( $current );
            update_option( 'active_plugins', $current );
        }

        if ( ! $silent ) {
            /** * Fires after a plugin has been activated. * * If a plugin is silently activated (such as during an update), * this hook does not fire. * * @since 2.9.0 * * @param string $plugin Path to the plugin file relative to the plugins directory. * @param bool $network_wide Whether to enable the plugin for all sites in the network * or just the current site. Multisite only. Default false. */

    public function save($data$id$tags = array()$specificLifetime = false)
    {
        $lifetime = $this->getLifetime($specificLifetime);
        if ($this->_options['compression']) {
            $flag = MEMCACHE_COMPRESSED;
        } else {
            $flag = 0;
        }

        // ZF-8856: using set because add needs a second request if item already exists         $result = @$this->_memcache->set($id, array($datatime()$lifetime)$flag$lifetime);

        if (count($tags) > 0) {
            $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND);
        }

        return $result;
    }

    /** * Remove a cache record * * @param string $id Cache id * @return boolean True if no problem */
$this->config = array_merge($this->config, $config->redis);
        }
    }

    /** * {@inheritDoc} */
    public function initialize()
    {
        try {
            $this->redis = new Client($this->config, ['prefix' => $this->prefix]);
            $this->redis->time();
        } catch (Exception $e) {
            throw new CriticalError('Cache: Predis connection refused (' . $e->getMessage() . ').');
        }
    }

    /** * {@inheritDoc} */
    public function get(string $key)
    {
        $key = static::validateKey($key);

        
if (null !== $result->error) {
                $ko[$key] = $result;
            }
        }

        return [] === $ko ? true : $ko;
    }

    private function normalizeExpiry(int $expiry): int
    {
        if ($expiry && $expiry > static::THIRTY_DAYS_IN_SECONDS) {
            $expiry += time();
        }

        return $expiry;
    }
}
'post_content'   => $file['url'],
                'post_mime_type' => $file['type'],
                'guid'           => $file['url'],
                'context'        => 'upgrader',
                'post_status'    => 'private',
            );

            // Save the data.             $this->id = wp_insert_attachment( $attachment$file['file'] );

            // Schedule a cleanup for 2 hours from now in case of failed installation.             wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );

        } elseif ( is_numeric( $_GET[ $urlholder ] ) ) {
            // Numeric Package = previously uploaded file, see above.             $this->id   = (int) $_GET[ $urlholder ];
            $attachment = get_post( $this->id );
            if ( empty( $attachment ) ) {
                wp_die( __( 'Please select a file' ) );
            }

            $this->filename = $attachment->post_title;
            $this->package  = get_attached_file( $attachment->ID );
        }

    public function initialize() {
        $this->is_initialized = true;

        add_action( 'wp_logout', array( $this, 'exit_recovery_mode' ) );
        add_action( 'login_form_' . self::EXIT_ACTION, array( $this, 'handle_exit_recovery_mode' ) );
        add_action( 'recovery_mode_clean_expired_keys', array( $this, 'clean_expired_keys' ) );

        if ( ! wp_next_scheduled( 'recovery_mode_clean_expired_keys' ) && ! wp_installing() ) {
            wp_schedule_event( time(), 'daily', 'recovery_mode_clean_expired_keys' );
        }

        if ( defined( 'WP_RECOVERY_MODE_SESSION_ID' ) ) {
            $this->is_active  = true;
            $this->session_id = WP_RECOVERY_MODE_SESSION_ID;

            return;
        }

        if ( $this->cookie_service->is_cookie_set() ) {
            $this->handle_cookie();

            

function current_time( $type$gmt = 0 ) {
    // Don't use non-GMT timestamp, unless you know the difference and really need to.     if ( 'timestamp' === $type || 'U' === $type ) {
        return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
    }

    if ( 'mysql' === $type ) {
        $type = 'Y-m-d H:i:s';
    }

    $timezone = $gmt ? new DateTimeZone( 'UTC' ) : wp_timezone();
    $datetime = new DateTime( 'now', $timezone );

    return $datetime->format( $type );
}


    public function __construct(
        Configuration $configuration,
        private readonly Connection $connection
    ) {
        $this->configuration = $configuration;
    }

    public function generateToken(TokenStruct $tokenStruct): string
    {
        $expires = new \DateTimeImmutable('@' . time());

        // @see https://github.com/php/php-src/issues/9950         if ($tokenStruct->getExpires() > 0) {
            $expires = $expires->modify(
                sprintf('+%d seconds', $tokenStruct->getExpires())
            );
        } else {
            $expires = $expires->modify(
                sprintf('-%d seconds', abs($tokenStruct->getExpires()))
            );
        }

        
/** @var \Drupal\language\Config\LanguageConfigOverride $view_config */
    // Ensure that views are translated as expected.     $view_config = \Drupal::languageManager()->getLanguageConfigOverride('es', 'views.view.who_s_new');
    $this->assertSame('Aplicar', $view_config->get('display.default.display_options.exposed_form.options.submit_button'));
    $view_config = \Drupal::languageManager()->getLanguageConfigOverride('es', 'views.view.archive');
    $this->assertSame('Aplicar', $view_config->get('display.default.display_options.exposed_form.options.submit_button'));

    // Manually update the translation status so can re-run the import.     $status = locale_translation_get_status();
    $status['drupal']['es']->type = 'local';
    $status['drupal']['es']->files['local']->timestamp = time();
    \Drupal::keyValue('locale.translation_status')->set('drupal', $status['drupal']);
    // Run the translation import.     $this->drupalGet('admin/reports/translations');
    $this->submitForm([], 'Update translations');

    // Ensure that only the config we expected to have changed has.     $comparer = $this->configImporter()->getStorageComparer();
    $expected_changelist_spanish_collection = [
      'create' => [],
      // The view was untranslated but the translation exists so the installer       // performs the translation.
    else if ($p_filedescr['type'] == 'virtual_file') {
      $p_header['external'] = 0x00000000;
      $p_header['size'] = strlen($p_filedescr['content']);
    }


    // ----- Look for filetime     if (isset($p_filedescr['mtime'])) {
      $p_header['mtime'] = $p_filedescr['mtime'];
    }
    else if ($p_filedescr['type'] == 'virtual_file') {
      $p_header['mtime'] = time();
    }
    else {
      $p_header['mtime'] = filemtime($p_filename);
    }

    // ------ Look for file comment     if (isset($p_filedescr['comment'])) {
      $p_header['comment_len'] = strlen($p_filedescr['comment']);
      $p_header['comment'] = $p_filedescr['comment'];
    }
    else {
      
$own_permission_user = $this->createUser(['view own workspace']);
    $any_permission_user = $this->createUser(['view any workspace']);
    $admin_permission_user = $this->createUser(['administer workspaces']);

    // Create the following workspace hierarchy:     // - top1 ($own_permission_user)     // --- child1_1 ($own_permission_user)     // --- child1_2 ($any_permission_user)     // ----- child1_2_1 ($any_permission_user)     // - top2 ($admin_permission_user)     // --- child2_1 ($admin_permission_user)     $created_time = \Drupal::time()->getCurrentTime();
    Workspace::create([
      'uid' => $own_permission_user->id(),
      'id' => 'top1',
      'label' => 'top1',
      'created' => ++$created_time,
    ])->save();
    Workspace::create([
      'uid' => $own_permission_user->id(),
      'id' => 'child1_1',
      'parent' => 'top1',
      'label' => 'child1_1',
      
Home | Imprint | This part of the site doesn't use cookies.