<commit_before><?php

namespace Backend\Modules\MediaLibrary\Actions;

use Backend\Core\Engine\Base\Action as BackendBaseAction;
use Backend\Core\Engine\Model;
use Backend\Modules\MediaLibrary\Domain\MediaFolder\Exception\MediaFolderNotFound;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Command\DeleteMediaItem;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Command\UpdateMediaItem;
use Backend\Modules\MediaLibrary\Domain\MediaFolder\MediaFolder;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Exception\MediaItemNotFound;
use Backend\Modules\MediaLibrary\Domain\MediaItem\MediaItem;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Type;
use Exception;

/**
 * This action is used to update one or more media items (move, ...)
 */
class MediaItemMassAction extends BackendBaseAction
{
    const MOVE = 'move';
    const DELETE = 'delete';

    private static $actions = [
        self::MOVE,
        self::DELETE,
    ];

    /** @var MediaFolder */
    protected $moveToMediaFolder;

    public function execute(): void
    {
        parent::execute();

        /** @var Type $selectedType */
        $selectedType = $this->getSelectedType();

        /** @var string $action */
        $action = $this->getSelectedAction();

        // Loop ids
        foreach ($this->getSelectedMediaItemIds() as $mediaItemId) {
            try {
                /** @var MediaItem $mediaItem */
                $mediaItem = $this->get('media_library.repository.item')->findOneById($mediaItemId);

                switch ($action) {
                    case self::MOVE:
                        $this->move($mediaItem, $selectedType);<commit_msg>Check csrf token before running a mass action Media Library module<commit_after><?php

namespace Backend\Modules\MediaLibrary\Actions;

use Backend\Core\Engine\Base\Action as BackendBaseAction;
use Backend\Core\Engine\Model;
use Backend\Modules\MediaLibrary\Domain\MediaFolder\Exception\MediaFolderNotFound;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Command\DeleteMediaItem;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Command\UpdateMediaItem;
use Backend\Modules\MediaLibrary\Domain\MediaFolder\MediaFolder;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Exception\MediaItemNotFound;
use Backend\Modules\MediaLibrary\Domain\MediaItem\MediaItem;
use Backend\Modules\MediaLibrary\Domain\MediaItem\Type;
use Exception;

/**
 * This action is used to update one or more media items (move, ...)
 */
class MediaItemMassAction extends BackendBaseAction
{
    const MOVE = 'move';
    const DELETE = 'delete';

    private static $actions = [
        self::MOVE,
        self::DELETE,
    ];

    /** @var MediaFolder */
    protected $moveToMediaFolder;

    public function execute(): void
    {
        parent::execute();

        $this->checkToken();

        /** @var Type $selectedType */
        $selectedType = $this->getSelectedType();

        /** @var string $action */
        $action = $this->getSelectedAction();

        // Loop ids
        foreach ($this->getSelectedMediaItemIds() as $mediaItemId) {
            try {
                /** @var MediaItem $mediaItem */
                $mediaItem = $this->get('media_library.repository.item')->findOneById($mediaItemId);

                switch ($action) {
                    case self::MOVE:
                        $this->move($mediaItem, $selectedType);
{'fraction_non_alphanumeric': 0.1177863273157739, 'fraction_numerical': 0.0, 'mean_word_length': 3.052757793764988, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, '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': '1889676', 'n_tokens_mistral': 929, 'n_tokens_neox': 922, 'n_words': 188}