Answer the question
In order to leave comments, you need to log in
How to deal with static class properties in PHP?
Hello!
I'm a little confused about the static properties of the class.
I am implementing one thing for Bitrix. So. There, when updating an information element, it is necessary to change the property values when it is updated, which, in turn, leads to a call to the same update procedure.
Some kind of flag could be used as a "preventor", which would say that we called the procedure a second time, we do not need to execute it.
It turned out something like this:
class UserHandlers
{
static $disableHandlerForUpdateOther = false;
//UPDATE ACTION
public static function OnAfterIBlockElementUpdateHandler(&$arFields) {
if (!self::$disableHandlerForUpdateOther) {
...
self::$disableHandlerForUpdateOther = true;
...
}
Answer the question
In order to leave comments, you need to log in
Do I understand correctly that if several elements are updated simultaneously in parallel , the situation will turn out that $disableHandlerForUpdateOther will probably have the value true at the beginning of the OnAfterIBlockElementUpdateHandler method execution?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question