P
P
Pavel Sidorov2021-11-16 18:11:24
1C-Bitrix
Pavel Sidorov, 2021-11-16 18:11:24

Why does the Bitrix agent error occur?

Agents on hits
There is an agent adFoo();

in php init

function adFoo()
{
    if(CModule::IncludeModule("iblock")){

      $el = new CIBlockElement;
      $IBLOCK_ID_CATALOG = 53; 
  
      $arLoadProductArray = Array( 
        "IBLOCK_ID" => $IBLOCK_ID_CATALOG,
        "NAME" => "тест1", 
        "ACTIVE" => "Y",
        "PREVIEW_TEXT" => "Позиция успешно добавлена",
      ); 
      $newElement = $el->Add($arLoadProductArray);
    }

return "adFoo();";
}

must add an element to the infoblock with a
period of 10 seconds

gives an error
6193c9e138773227799377.jpeg

I started a simple agent with a period of 10 seconds sending a test to the mail

function testAgent()
{
mail('mail', 'Agent', 'Agent');
return "testAgent();";
}
runs every 10 sec.

explain, pAmagiti!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-11-16
@pavel__sidorov

I will assume that $USER->GetID() is called, the documentation states that the $USER variable is not in the agents. . Apparently, this module has an event for adding an infoblock element, in which $USER->GetID() is called, and so on. $USER=null and not an object of class CUser you get an error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question