You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Kate Gray (Jira)" <ji...@apache.org> on 2019/10/26 21:58:00 UTC

[jira] [Commented] (LOG4PHP-234) Two plugin using log4php produces Fatal, although include_once used

    [ https://issues.apache.org/jira/browse/LOG4PHP-234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16960442#comment-16960442 ] 

Kate Gray commented on LOG4PHP-234:
-----------------------------------

This error is due to the way PHP handles including and class definition files.  When using composer and autoloading, this won't pop up.  Wordpress plugins generally won't work this way.

It sounds like the plugins use the method described in the documentation:
{code:java}
include('Logger.php');
$logger = Logger::getLogger("main");
{code}

Unfortunately, even require_once won't necessarily fix things if they have two separate include files.

It's possible to handle conflicts through the use of something like checking if the class exists, but this can cause issues if versions differ significantly - whatever plugin loads first will be responsible for loading the logger.

Do you mind if I ask which plugins are affected?  If so, I may be able to contact the developers to suggest some fixes.

> Two plugin using log4php produces Fatal, although include_once used
> -------------------------------------------------------------------
>
>                 Key: LOG4PHP-234
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-234
>             Project: Log4php
>          Issue Type: Bug
>         Environment: ubuntu LTS 16
>            Reporter: Max UNGER
>            Priority: Critical
>
> Two wordpress plugins on the same install using log4php, loaded as explained in doc produce fatal error when used together:
> PHP Fatal error:  Cannot declare class LoggerAutoloader, because the name is already in use in /var/www/yyyyyyy.com/wp-content/plugins/myplugin/libs/log4php/2.3.0/LoggerAutoloader.php on line 34
> no change if include_once used instead of include



--
This message was sent by Atlassian Jira
(v8.3.4#803005)