facebook-for-magento2
facebook-for-magento2 copied to clipboard
LogOrganization.php doesn't support pub docroot
Contact Details
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
Getting a similar error:
Magento Version: 2.4.3-p1 Plugin Version: 1.4.3 PHP Version: 7.4
Step's to replicate:
- Login to admin panel
- Go to Stores > Facebook > Info
- 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)"} []
Hello
is anyone solve this issue?
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
andfbaccesstoken/creation_time
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 ;)