<commit_before><?php
/**
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\Command;

use OCP\Command\IBus;
use OCP\Command\ICommand;

class QueueBus implements IBus {
	/**
	 * @var (ICommand|callable)[]
	 */
	private $queue = [];

	/**
	 * Schedule a command to be fired
	 *
	 * @param \OCP\Command\ICommand | callable $command
	 */
	public function push($command) {
		$this->queue[] = $command;
	}

	/**
	 * Require all commands using a trait to be run synchronous
	 *
	 * @param string $trait
	 */
	public function requireSync($trait) {
	}

	/**
	 * @param \OCP\Command\ICommand | callable $command
	 */
	private function runCommand($command) {
		if ($command instanceof ICommand) {
			// ensure the command can be serialized
			$serialized = serialize($command);
			$unserialized = unserialize($serialized);
			$unserialized->handle();
		} else {
			$command();
		}
	}<commit_msg>check limit of serialized command in unit tests<commit_after><?php
/**
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\Command;

use OCP\Command\IBus;
use OCP\Command\ICommand;

class QueueBus implements IBus {
	/**
	 * @var (ICommand|callable)[]
	 */
	private $queue = [];

	/**
	 * Schedule a command to be fired
	 *
	 * @param \OCP\Command\ICommand | callable $command
	 */
	public function push($command) {
		$this->queue[] = $command;
	}

	/**
	 * Require all commands using a trait to be run synchronous
	 *
	 * @param string $trait
	 */
	public function requireSync($trait) {
	}

	/**
	 * @param \OCP\Command\ICommand | callable $command
	 */
	private function runCommand($command) {
		if ($command instanceof ICommand) {
			// ensure the command can be serialized
			$serialized = serialize($command);
			if(strlen($serialized) > 4000) {
				throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
			}
			$unserialized = unserialize($serialized);
			$unserialized->handle();
		} else {
			$command();
		}
	}
{'fraction_non_alphanumeric': 0.13360142984807863, 'fraction_numerical': 0.00804289544235925, 'mean_word_length': 3.451292246520875, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3691543', 'n_tokens_mistral': 771, 'n_tokens_neox': 694, 'n_words': 214}