facebook-for-magento2 icon indicating copy to clipboard operation
facebook-for-magento2 copied to clipboard

LogOrganization.php doesn't support pub docroot

Open johanvanzijl opened this issue 3 years ago • 4 comments

Contact Details

[email protected]

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

  • [X] I agree to follow this project's Code of Conduct

johanvanzijl avatar Oct 14 '21 08:10 johanvanzijl

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)"} []

lytesaber avatar Nov 04 '21 05:11 lytesaber

Hello

is anyone solve this issue?

purvid0204 avatar Nov 18 '21 14:11 purvid0204

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

wmdkdkussin avatar Nov 23 '21 09:11 wmdkdkussin

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 ;)

guztavoalves avatar Jun 11 '22 20:06 guztavoalves