<commit_before><?php
/**
 * @package deployment
 * @subpackage base.permissions
 * 
 * Adds all system default permissions
 */

chdir(__DIR__);
require_once('../../bootstrap.php');

$dirPath = realpath(__DIR__ . '/../../') . '/permissions';
$scriptPath = realpath(__DIR__ . '/../../../') . '/scripts/utils/permissions/addPermissionsAndItems.php';

KalturaLog::info("Adding permissions from directory [$dirPath]");
$dir = dir($dirPath);
/* @var $dir Directory */

$returnValue = null;
while (false !== ($fileName = $dir->read()))
{
	$filePath = realpath("$dirPath/$fileName");
	if($fileName[0] == '.')
		continue;

	KalturaLog::info("Adding permissions from file [$filePath]");
	passthru("php $scriptPath $filePath", $returnValue);
	if($returnValue !== 0)
		exit(-1);
}<commit_msg>qnd: execute first all the files that add permissions<commit_after><?php
/**
 * @package deployment
 * @subpackage base.permissions
 * 
 * Adds all system default permissions
 */

chdir(__DIR__);
require_once('../../bootstrap.php');

$dirPath = realpath(__DIR__ . '/../../') . '/permissions';
$scriptPath = realpath(__DIR__ . '/../../../') . '/scripts/utils/permissions/addPermissionsAndItems.php';

KalturaLog::info("Adding permissions from directory [$dirPath]");
$dir = dir($dirPath);
/* @var $dir Directory */

$files = array();
$returnValue = null;
while (false !== ($fileName = $dir->read()))
{
	if($fileName[0] == '.')
		continue;

	$files[] = $fileName;
}

// execute first all the files that add permissions
foreach($files as $index => $fileName)
{
	$filePath = realpath("$dirPath/$fileName");
	if(!preg_match('/\[permissions\]/', file_get_contents($filePath)))
		continue;
	
	unset($files[$index]);
	KalturaLog::info("Adding permissions from file [$filePath]");
	passthru("php $scriptPath $filePath", $returnValue);
	if($returnValue !== 0)
		exit(-1);
}

// execute all other files
foreach($files as $index => $fileName)
{
	$filePath = realpath("$dirPath/$fileName");
	KalturaLog::info("Adding permissions from file [$filePath]");
	passthru("php $scriptPath $filePath", $returnValue);
	if($returnValue !== 0)
		exit(-1);
}
{'fraction_non_alphanumeric': 0.20549242424242425, 'fraction_numerical': 0.003787878787878788, 'mean_word_length': 4.804945054945055, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1360524', 'n_tokens_mistral': 700, 'n_tokens_neox': 688, 'n_words': 150}