[Phpmyadmin-devel] Any special reason that "require" but not "require _once" on libraries/common.inc.php

Dieter Adriaenssens dieter.adriaenssens at gmail.com
Thu May 16 20:21:19 CEST 2013


2013/5/16 adam <adamgsoc2013 at gmail.com>:
> Hi,
>
> Although I changed the "require" to "require _once" on libraries/common.inc.php
> other redefine error still existed:
> https://travis-ci.org/phpmyadmin/phpmyadmin/jobs/7223416
>
> so I think to test the files which requires "libraries/common.inc.php", the problem will exist.
>
> Any advice? thanks

Using require_once, will only include the file if it wasn't included
before, see [0].
If you use require, it will include the file, regardless if it was
included at another place or in another included file. If a function
or class is defined in a file that was included before, you get the
error that you mention.
Because keeping track of where which files were included, is too
complicated, using require_once is the best option.

Hope this helps.

[0] http://www.php.net/manual/en/function.require-once.php


>
> Adam
>
>>Hi all,
>>
>>I make pull request about adding Unit test case for  libraries/ServerStatusData.class.php
>>https://github.com/phpmyadmin/phpmyadmin/pull/394
>>
>>but a build error if I don't change the "require" to "require _once" on libraries/common.inc.php
>>https://travis-ci.org/phpmyadmin/phpmyadmin/jobs/7221724
>>
>>it is:
>>Fatal error: Cannot redeclare class PMA_Error_Handler in /home/travis/build/phpmyadmin/phpmyadmin/libraries/Error_Handler.class.php on line 20
>>
>>
>>I want to know that Any special reason that "require" but not "require _once" on libraries/common.inc.php
>>
>>
>>thanks,
>>Adam
>>------------------------------------------------------------------------------
>>AlienVault Unified Security Management (USM) platform delivers complete
>>security visibility with the essential security capabilities. Easily and
>>efficiently configure, manage, and operate all of your security controls
>>from a single console and one unified framework. Download a free trial.
>>http://p.sf.net/sfu/alienvault_d2d
>>_______________________________________________
>>Phpmyadmin-devel mailing list
>>Phpmyadmin-devel at lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
> ------------------------------------------------------------------------------
> AlienVault Unified Security Management (USM) platform delivers complete
> security visibility with the essential security capabilities. Easily and
> efficiently configure, manage, and operate all of your security controls
> from a single console and one unified framework. Download a free trial.
> http://p.sf.net/sfu/alienvault_d2d
> _______________________________________________
> Phpmyadmin-devel mailing list
> Phpmyadmin-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel



--
Kind regards,

Dieter Adriaenssens




More information about the Developers mailing list