<commit_before><?php
namespace wcf\system\package;
use wcf\data\package\installation\queue\PackageInstallationQueueEditor;
use wcf\data\package\installation\queue\PackageInstallationQueueList;
use wcf\data\package\Package;
use wcf\system\exception\SystemException;
use wcf\system\Callback;
use wcf\system\WCF;
use wcf\util\FileUtil;
use wcf\util\StringUtil;

/**
 * Creates a logical node-based installation tree.
 * 
 * @author	<NAME>
 * @copyright	2001-2014 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.package
 * @category	Community Framework
 */
class PackageInstallationNodeBuilder {
	/**
	 * true if current node is empty
	 * @var	boolean
	 */
	public $emptyNode = true;
	
	/**
	 * active package installation dispatcher
	 * @var	\wcf\system\package\PackageInstallationDispatcher
	 */
	public $installation = null;
	
	/**
	 * current installation node
	 * @var	string
	 */
	public $node = '';
	
	/**
	 * current parent installation node
	 * @var	string
	 */
	public $parentNode = '';
	
	/**
	 * list of requirements to be checked before package installation
	 * @var	array<array>
	 */
	public $requirements = array();
	
	/**
	 * current sequence number within one node
	 * @var	integer
	 */
	public $sequenceNo = 0;
	
	/**
	 * list of packages about to be installed
	 * @var	array<string>
	 */
	protected static $pendingPackages = array();
	
	/**
	 * Creates a new instance of PackageInstallationNodeBuilder
	 * 
	 * @param	PackageInstallationDispatcher	$installation
	 */
	public function __construct(PackageInstallationDispatcher $installation) {
		$this->installation = $installation;
	}
	
	/**
	 * Sets parent node.
	 * 
	 * @param	string		$parentNode
	 */
	public function setParentNode($parentNode) {
		$this->parentNode = $parentNode;
	}
	
	/**
	 * Builds nodes for current installation queue.
	 */
	public function buildNodes() {
		// required packages
		$this->buildRequirementNodes();
		
		// register package version
		self::$pendingPackages[$this->installation->getArchive()->getPackageInfo('name')] = $this->installation->getArchive()->getPackageInfo('version');
		
		// install package itself
		if ($this->installation->queue->action == 'install') {
			$this->buildPackageNode();
		}
		
		// package installation plugins
		$this->buildPluginNodes();
		
		// optional packages (ignored on update)
		if ($this->installation->queue->action == 'install') {
			$this->buildOptionalNodes();
		}
		
		// child queues
		$this->buildChildQueues();
		
		if ($this->installation->queue->action == 'update') {
			$this->buildPackageNode();
		}
	}
	
	/**
	 * Returns the succeeding node.
	 * 
	 * @param	string		$parentNode<commit_msg>Fixed multistep updates updating the version number in the wrong order<commit_after><?php
namespace wcf\system\package;
use wcf\data\package\installation\queue\PackageInstallationQueueEditor;
use wcf\data\package\installation\queue\PackageInstallationQueueList;
use wcf\data\package\Package;
use wcf\system\exception\SystemException;
use wcf\system\Callback;
use wcf\system\WCF;
use wcf\util\FileUtil;
use wcf\util\StringUtil;

/**
 * Creates a logical node-based installation tree.
 * 
 * @author	<NAME>
 * @copyright	2001-2014 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	com.woltlab.wcf
 * @subpackage	system.package
 * @category	Community Framework
 */
class PackageInstallationNodeBuilder {
	/**
	 * true if current node is empty
	 * @var	boolean
	 */
	public $emptyNode = true;
	
	/**
	 * active package installation dispatcher
	 * @var	\wcf\system\package\PackageInstallationDispatcher
	 */
	public $installation = null;
	
	/**
	 * current installation node
	 * @var	string
	 */
	public $node = '';
	
	/**
	 * current parent installation node
	 * @var	string
	 */
	public $parentNode = '';
	
	/**
	 * list of requirements to be checked before package installation
	 * @var	array<array>
	 */
	public $requirements = array();
	
	/**
	 * current sequence number within one node
	 * @var	integer
	 */
	public $sequenceNo = 0;
	
	/**
	 * list of packages about to be installed
	 * @var	array<string>
	 */
	protected static $pendingPackages = array();
	
	/**
	 * Creates a new instance of PackageInstallationNodeBuilder
	 * 
	 * @param	PackageInstallationDispatcher	$installation
	 */
	public function __construct(PackageInstallationDispatcher $installation) {
		$this->installation = $installation;
	}
	
	/**
	 * Sets parent node.
	 * 
	 * @param	string		$parentNode
	 */
	public function setParentNode($parentNode) {
		$this->parentNode = $parentNode;
	}
	
	/**
	 * Builds nodes for current installation queue.
	 */
	public function buildNodes() {
		// required packages
		$this->buildRequirementNodes();
		
		// register package version
		self::$pendingPackages[$this->installation->getArchive()->getPackageInfo('name')] = $this->installation->getArchive()->getPackageInfo('version');
		
		// install package itself
		if ($this->installation->queue->action == 'install') {
			$this->buildPackageNode();
		}
		
		// package installation plugins
		$this->buildPluginNodes();
		
		// optional packages (ignored on update)
		if ($this->installation->queue->action == 'install') {
			$this->buildOptionalNodes();
		}
		
		if ($this->installation->queue->action == 'update') {
			$this->buildPackageNode();
		}
		
		// child queues
		$this->buildChildQueues();
	}
	
	/**
	 * Returns the succeeding node.
	 * 
	 * @param	string		$parentNode
{'fraction_non_alphanumeric': 0.13000538696354821, 'fraction_numerical': 0.003232178128927994, 'mean_word_length': 3.7566182749786505, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 57, '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': '3319931', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1596, 'n_words': 403}