sypets / brofix

Check for broken links, forked from TYPO3 system extension linkvalidator
Other
6 stars 8 forks source link

Exception in scheduler #362

Closed dmitryd closed 4 months ago

dmitryd commented 4 months ago

Describe the bug

TYPO3 v11 is probably old but I cannot test on v12 yet.

I added check links command via scheduler with no parameters. TSConfig is as follows:

mod {
    brofix {
        mail {
            sendOnCheckLinks = never
        }
        searchFields {
            tt_content := addToList(pi_flexform)
        }
    }
}

When executing the job manually via scheduler, scheduler shows an exception:

txschedulerM1.html.zip

It seems like after executing of this command it cannot find user session anymore. Any other schedulable command does not have this issue.

The cause of the problem seems to be this:

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        // link checking (in particular FormEngine processing with FormDataCompiler) requires an initialized session
        // due to AbstractUserAuthentication::getModuleData called from Clipboard::initializeClipboard called from TcaGroup::addData
        // see https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/DataHandler/UsingDataHandler/Index.html#dataHandler-cli-command
        \TYPO3\CMS\Core\Core\Bootstrap::initializeBackendAuthentication();
        $GLOBALS['BE_USER']->initializeUserSessionManager();

Commenting the last line above makes scheduler work again. It looks like this line is not needed in the Backend context.

System (please complete the following information):

sypets commented 4 months ago

@dmitryd v11 is ok, I am also using v11. I assume the problem is related to running the scheduler task in the BE (not via command ) and is related to the changes I made recently for support of flexforms. I will investigate and provide a fix. I will try to do that on Friday, if possible earlier.

As workaround - if you can - please try to run this the via the console command in the command line (or via cron), e.g.

php vendor/bin/typo3 brofix:checklinks

dmitryd commented 4 months ago

Yes, correct, execution via Backend. I made a MR because we needed a fix.

Great extension by the way! I love it!!! 👍

sypets commented 4 months ago

Thanks, the fix looks good. Is there any time pressure on your end for merging this and creating a release? (I am kind of tied up right now and would like to do some proper testing).

Great to hear you like the extension :smile:

dmitryd commented 4 months ago

Is there any time pressure on your end for merging this and creating a release?

No hurry, take your time. We use composer patching for such cases, so we can live with a local patch until you have time to integrate it :)