facebookarchive / facebook-for-magento2

* Pixel on all pages, which trigger events link, PageView, ViewContent, AddToCart, Initiatecheckout and Purchase.* In the background, Syncs the products from the merchants product catalog to Facebook Catalog.* Stores all the data, like pixel id, catalog id, business maanger id, on to the local database on the instance.
Other
46 stars 36 forks source link

LogOrganization.php doesn't support pub docroot #88

Open johanvanzijl opened 2 years ago

johanvanzijl commented 2 years ago

Contact Details

johan@connset.co.za

What happened?

When the Magento docroot is configured to be served from the pub directory as described here, the Info page terminates with the undefined fp error shown below.

This error is due to the code on line 74, being outside the For loop(fp is never initialised if none of the files are found). Once that error has been corrected, a second failed to open stream exception will occur on line 91.

The proposed changes are listed in my forked repository here: https://github.com/johanvanzijl/facebook-for-magento2/blob/main/Helper/LogOrganization.php.

Magento Version

2.4.2-p2

Plugin Version

1.4.3

Relevant log output

1 exception(s):
Exception #0 (Exception): Notice: Undefined variable: fp in /var/www/html/magento2/vendor/facebook/facebook-for-magento2/Helper/LogOrganization.php on line 74

1 exception(s):
Exception #0 (Exception): Warning: fopen(var/log/facebook-business-extension.log): failed to open stream: No such file or directory in /var/www/html/magento2/vendor/facebook/facebook-for-magento2/Helper/LogOrganization.php on line 91

Code of Conduct

lytesaber commented 2 years ago

Getting a similar error:

Magento Version: 2.4.3-p1 Plugin Version: 1.4.3 PHP Version: 7.4

Step's to replicate:

  1. Login to admin panel
  2. Go to Stores > Facebook > Info
  3. Exception thrown in Magento's exception.log file

Exception.log Error: main.CRITICAL: Notice: Undefined variable: fp in /var/www/html/vendor/facebook/facebook-for-magento2/Helper/LogOrganization.php on line 74 {"exception":"[object] (Exception(code: 0): Notice: Undefined variable: fp in /var/www/html/vendor/facebook/facebook-for-magento2/Helper/LogOrganization.php on line 74 at /var/www/html/vendor/magento/framework/App/ErrorHandler.php:61)"} []

purvid0204 commented 2 years ago

Hello

is anyone solve this issue?

wmdkdkussin commented 2 years ago

We have the same issue with Magento v2.4.2-p1 (Modul: v1.4.3 & FB API: v12.0) and we connected to Facebook with the Wizzard but if I reload the page it asked me again to connect but in the db table facebook_business_extension_config all settings are shown. - Maybe this issue is connected. Does anyone can confirm this issue, too?

EDIT wmdk_dkussin/2021-11-23:

The connection ist gone after logging out and back in. If we run the wizzard again it only updates facebook_business_extension_config.config_key: fbpixel/aam_settings, fbprofile/ids, fbaccess/token and fbaccesstoken/creation_time

01_FB_Business_connected 02_FB_Business_disconnected

guztavoalves commented 2 years ago

In file vendor\facebook\facebook-for-magento2\Helper\LogOrganization.php on line 74 change

fclose($fp);

with

if(isset($fp))
{
    fclose($fp);
}

The $fp is set inside of $arrayOfFiles foreach loop, but this loop 'continue' when the log file not exists:

foreach($arrayOfFiles as $value) {

            if (!file_exists($value)) {
                continue;
            }
          // --------- ^

... the loop finish and $fp is nothing seted, but on line 74 we trying fclose($fp), an indefined variable.

Work for me ;)