<commit_before><?php

namespace SilverStripe\Subsites\Tasks;

use InvalidArgumentException;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\BuildTask;
use SilverStripe\ORM\DataObject;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\Pages\SubsitesVirtualPage;
use SilverStripe\Versioned\Versioned;

/**
 * Handy alternative to copying pages when creating a subsite through the UI.
 *
 * Can be used to batch-add new pages after subsite creation, or simply to
 * process a large site outside of the UI.
 *
 * Example: sake dev/tasks/SubsiteCopyPagesTask from=<subsite-source> to=<subsite-target>
 *
 * @package subsites
 */
class SubsiteCopyPagesTask extends BuildTask
{
    protected $title = 'Copy pages to different subsite';
    protected $description = '';

    public function run($request)
    {
        $subsiteFromId = $request->getVar('from');
        if (!is_numeric($subsiteFromId)) {
            throw new InvalidArgumentException('Missing "from" parameter');
        }
        $subsiteFrom = DataObject::get_by_id(Subsite::class, $subsiteFromId);
        if (!$subsiteFrom) {
            throw new InvalidArgumentException('Subsite not found');
        }

        $subsiteToId = $request->getVar('to');
        if (!is_numeric($subsiteToId)) {
            throw new InvalidArgumentException('Missing "to" parameter');<commit_msg>NEW Add segment to SubsiteCopyPageTask<commit_after><?php

namespace SilverStripe\Subsites\Tasks;

use InvalidArgumentException;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Dev\BuildTask;
use SilverStripe\ORM\DataObject;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\Pages\SubsitesVirtualPage;
use SilverStripe\Versioned\Versioned;

/**
 * Handy alternative to copying pages when creating a subsite through the UI.
 *
 * Can be used to batch-add new pages after subsite creation, or simply to
 * process a large site outside of the UI.
 *
 * Example: sake dev/tasks/SubsiteCopyPagesTask from=<subsite-source> to=<subsite-target>
 *
 * @package subsites
 */
class SubsiteCopyPagesTask extends BuildTask
{
    protected $title = 'Copy pages to different subsite';
    protected $description = '';

    private static $segment = 'SubsiteCopyPagesTask';

    public function run($request)
    {
        $subsiteFromId = $request->getVar('from');
        if (!is_numeric($subsiteFromId)) {
            throw new InvalidArgumentException('Missing "from" parameter');
        }
        $subsiteFrom = DataObject::get_by_id(Subsite::class, $subsiteFromId);
        if (!$subsiteFrom) {
            throw new InvalidArgumentException('Subsite not found');
        }

        $subsiteToId = $request->getVar('to');
        if (!is_numeric($subsiteToId)) {
            throw new InvalidArgumentException('Missing "to" parameter');
{'fraction_non_alphanumeric': 0.10460992907801418, 'fraction_numerical': 0.0, 'mean_word_length': 3.8890814558058926, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6869394', 'n_tokens_mistral': 826, 'n_tokens_neox': 804, 'n_words': 209}