Menu

#3823 Anonymous function issue with PHP 5.2.8 (when clicking on "Export" menu)

4.0.0
fixed
None
5
2014-02-17
2013-02-13
JT Graveaud
No

Looks like I have another compatibility issue with PHP5.2

[13-Feb-2013 03:24:28] PHP Parse error: syntax error, unexpected T_FUNCTION in /web/libraries/properties/options/OptionsPropertyGroup.class.php on line 62 (see below)
[13-Feb-2013 03:24:28] PHP Stack trace:
[13-Feb-2013 03:24:28] PHP 1. {main}() /web/db_export.php:0
[13-Feb-2013 03:24:28] PHP 2. require_once() /web/db_export.php:86
[13-Feb-2013 03:24:28] PHP 3. PMA_getPlugins() /web/libraries/display_export.lib.php:44
[13-Feb-2013 03:24:28] PHP 4. ExportHtmlword->__construct() /web/libraries/plugin_interface.lib.php:74
[13-Feb-2013 03:24:28] PHP 5. ExportHtmlword->setProperties() /web/libraries/plugins/export/ExportHtmlword.class.php:29
[13-Feb-2013 03:24:28] PHP 6. include_once() /web/libraries/plugins/export/ExportHtmlword.class.php:41

The issue appears when I click the "Export" menu.

I think the issue is due to the anonymous function available only in PHP 5.3.
see http://php.net/manual/en/functions.anonymous.php

This issue appears on the release PMA 4.0.0

public function removeProperty($property)
{
    $this->_properties = array_udiff(
        $this->getProperties(),
        array($property),
        function ($a, $b) {
            return ($a === $b ) ? 0 : 1;
        }
    );
}

Sorry, I don't have the time right now to investigate, but let me know if you need me at some point to test something.

Thanks
JT

Discussion

  • JT Graveaud

    JT Graveaud - 2013-02-13

    FYI, as a quick fix on my side I defined the following function after the end of the class implementation in the same file OptionsPropertyGroup.class.php

    function removeProperty_compare($a, $b) {
      return ($a === $b ) ? 0 : 1;
    }
    

    and in the initial error location, I replaced the anonymous function by its "pointer".

    public function removeProperty($property)
    {
        $this->_properties = array_udiff(
            $this->getProperties(),
            array($property), removeProperty_compare
        );
    }
    

    So, at least, you know this is working on my side, I let you make this cleaner ;-)

    Cheers.
    JT

     
  • Marc Delisle

    Marc Delisle - 2013-02-13
    • assigned_to: Marc Delisle
     
  • Marc Delisle

    Marc Delisle - 2013-02-13

    JT,
    I cannot reproduce this with PHP 5.2.8. I click on Export menu at the server, db or table level and get no error message.

     
  • Marc Delisle

    Marc Delisle - 2013-02-18

    Dieter suggests that this was fixed in commit https://github.com/phpmyadmin/phpmyadmin/commit/c3f27965. Closing for now.

     
  • Marc Delisle

    Marc Delisle - 2013-02-18
    • status: open --> closed-fixed
     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: closed-fixed --> fixed
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.