Jump to content

include several HTML banners with asyncjs


Sergei

Recommended Posts

I use asyncjs for including all banners on the page. I 've inserted "invoke code" and so on.. All zones are being collected and the standart js script sent this bunch of the zone ids to the server.

Now I need use two kind of the html banners : 1) generic ; 2) html5 (zip); 

When both kind of the baners  should be showed on the page  and the request is sent to asyncspc.php i get fatal error there:

Fatal error: Cannot redeclare Plugin_BannerTypeHTML_delivery_adRender() (previously declared in /var/www/adv/lib/OX/Extension/bannerTypeHtml/bannerTypeHtmlDelivery.php:31) in /var/www/adv/lib/OX/Extension/bannerTypeHtml/bannerTypeHtmlDelivery.php on line 31

After some debug i can add what i think:

1) there is foreach in function OX_Delivery_Common_getFunctionFromComponentIdentifier  that processes all zone ids and include the files that is needed for rendering each kind of the banners.

2) when zone with generic html banner is being processed  file plugins/bannerTypeHtml/oxHtml/html5.delivery.php is included.

3) there is call of   _adRenderHtml in function Plugin_BannerTypeHTML_oxHtml_html5_Delivery_adRender in file html5.delivery.php

4)_adRenderHtml  includes the file with function Plugin_BannerTypeHTML_delivery_adRender from that fatal error.

5) after that html5(zip) banner is being processed and there is the second time when this function  is included 

6) result is the fatal error.

There is checking "function_exists" don't work because functions are included inside of the function. This way make "function_exists" to return "false".

Quesiton: is it issue or I do something wrong with this functional

Thanks.

Sorry for my english, below the same explanation in russian.

-------------------------
Я использую asyncjs для того чтобы вывести все баннеры. Вставил "вызывающий код " и так далее.. В общем, все id зон собираются и с помощью одного запроса, так сказать, пачкой, отправляются на сервер.
Теперь мне нужно на ровне с generic баннерами использовать html5(zip) баннеры, но когда на странице должны выводится оба вида этих баннеров у меня появляется ошибка при исполнении asyncspc.php.

Fatal error: Cannot redeclare Plugin_BannerTypeHTML_delivery_adRender() (previously declared in /var/www/adv/lib/OX/Extension/bannerTypeHtml/bannerTypeHtmlDelivery.php:31) in /var/www/adv/lib/OX/Extension/bannerTypeHtml/bannerTypeHtmlDelivery.php on line 31

Немного подебажил:

1) в OX_Delivery_Common_getFunctionFromComponentIdentifier есть foreach который перебирает зоны и подключает нужные файлы с функциями для обработки того или иного вида 

2) Когда обрабатывается зона для generic баннера подключается файл plugins/bannerTypeHtml/oxHtml/html5.delivery.php

3) там функция вызывающая _adRenderHtml

4) в _adRenderHtml подключается файл с той функцией из фатальной ошибки 

5) затем обрабатывается html5 zip баннер и он подключает нужный для этого файл

6) результат функция подключается дважды

Проверка с function_exists здесь не работает так как подключение происходит внутри функции. Это заставляет function_exists вернуть false 

Вопрос: это баг или я что-то делаю не так с этим asincjs?

Link to comment
Share on other sites

  • 2 weeks later...

If it will be intresting for someone.
I have solved the problem, but desision is  rough a bit.

Fatal error: Cannot redeclare Plugin_BannerTypeHTML_delivery_adRender() (previously declared in /var/www/adv/lib/OX/Extension/bannerTypeHtml/bannerTypeHtmlDelivery.php:31) in /var/www/adv/lib/OX/Extension/bannerTypeHtml/bannerTypeHtmlDelivery.php on line 31
Jrf


I added this check

if ( ! function_exists('Plugin_BannerTypeHTML_delivery_adRender')) {}

right into the file that contains Plugin_BannerTypeHTML_delivery_adRender

Cause of the problem:

Function OX_Delivery_Common_getFunctionFromComponentIdentifier.

there is   :
  if (!function_exists($functionName)) {
        if (!empty($GLOBALS['_MAX']['CONF']['pluginSettings']['useMergedFunctions'])) {
            _includeDeliveryPluginFile('/var/cache/' . OX_getHostName() . '_mergedDeliveryFunctions.php');
        }
        if (!function_exists($functionName)) {
            _includeDeliveryPluginFile($GLOBALS['_MAX']['CONF']['pluginPaths']['plugins'] . '/' . implode('/', $aInfo)
                . '.delivery.php');
            if (!function_exists($functionName)) {
                _includeDeliveryPluginFile('/lib/OX/Extension/' . $aInfo[0] . '/' . $aInfo[0] . 'Delivery.php');
                $functionName = 'Plugin_' . $aInfo[0] . '_delivery';
                if (!empty($hook) && function_exists($functionName . '_' . $hook)) {
                    $functionName .= '_' . $hook;
                }
            }
        }
    }

There is no check on existing  another fuction, it is more correct:


            if (!function_exists($functionName)) {
                $functionName = 'Plugin_' . $aInfo[0] . '_delivery';

                if (!function_exists($functionName)) {
                    _includeDeliveryPluginFile('/lib/OX/Extension/' . $aInfo[0] . '/' . $aInfo[0] . 'Delivery.php');
                }

                if (!empty($hook) && function_exists($functionName . '_' . $hook)) {
                    $functionName .= '_' . $hook;
                }
            }

 

PS: I don't create issue about it on github, because there is same topic with admin's post , that i hadn't find before - Maybe this bug had been fixed already, but i don't have the newest version...

Sorry for my english and maybe I've created this topic in wrong category.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...