Skip to main content
Topic: [ADDON] Ultimate Menu (Read 13528 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: [ADDON] Ultimate Menu

Reply #75
After the update to ElkArte 1.1.4  I get this error message for three lines (167, 183 and 216), if I go to the Ultimate Menu in the ACP:

Unknown Error: Function create_function() is deprecated
https://forum.website.de/index.php?action=admin;area=umen;sa=manmenu;lC6YqBG=ug0ThYsUqmmXa9Afj6CjjDCu77ZB9HWn
-> ManageUltimateMenu.controller.php


Can someone help, please?
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7

Re: [ADDON] Ultimate Menu

Reply #76
That’s due to your version of php you’re running, not the Elkarte update.

They need to be changed to anonymous functions. http://php.net/manual/en/functions.anonymous.php

I can’t look at it now but should be able to tomorrow if you can’t work out the changes.

Re: [ADDON] Ultimate Menu

Reply #77
Aha, the PHP version is to blame . It's now PHP 7.2.1.

It would be nice if you did that for me. I've looked at it and understood only a little... O:-)
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7

Re: [ADDON] Ultimate Menu

Reply #78
It simply means to convert all create_function to function. It shouldn't be that hard. Find and list them here if you are not sure.

Re: [ADDON] Ultimate Menu

Reply #79
To do it by myself unfortunately exceeds my knowledge.
Here are the parts with create_function in it. It's always in the second line.
The complete page is attached below.

Code: [Select]
                    'data' => array(
                        'function' => create_function('$rowData', '
                            global $txt;

                            return $txt[$rowData[\'type\'] . \'_link\'];
                        '),
                    ),

Code: [Select]
                    'data' => array(
                        'function' => create_function('$rowData', '
                            global $txt;

                            // Don\'t show the stub name if we can find the parent name
                            $check = common_um_name($rowData[\'parent\']);
                            $name = !empty($check) ? $check : $rowData[\'parent\'];

                            return $txt[\'mboards_order_\' . $rowData[\'position\']] . \' \' . ucwords($name);
                        '),
                    ),

Code: [Select]
                    'data' => array(
                        'function' => create_function('$rowData', '
                            global $txt;

                            $isChecked = $rowData[\'status\'] === \'inactive\' ? \'\' : \' checked="checked"\';
                            return sprintf(\'<span>%3$s</span>&nbsp;<input type="checkbox" name="status[%1$s]" id="status_%1$s" value="%1$s"%2$s />\', $rowData[\'id_button\'], $isChecked, $txt[$rowData[\'status\']], $rowData[\'status\']);
                        '),
                        'class' => 'centertext',
                    ),
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7

Re: [ADDON] Ultimate Menu

Reply #80
Here is an example of the first one, I think it should work...

Code: [Select]
'data' => array (
    function ($rowData ) use ( $txt ) {
        return $txt[$rowData['type'] . '_link'];
    }
),

Re: [ADDON] Ultimate Menu

Reply #81
My second:

Code: [Select]
'data' => array (
    function ($rowData ) use ( $txt ) {

    // Don\'t show the stub name if we can find the parent name
    $check = common_um_name($rowData['parent']);
    $name = !empty($check) ? $check : $rowData['parent'];

    return $txt['mboards_order_' . $rowData['position']] . ' ' . ucwords($name);
    }
),


and my third:

Code: [Select]
'data' => array (
     function ($rowData ) use ( $txt ) {

    $isChecked = $rowData['status'] === 'inactive' ? '' : ' checked="checked"';
     return sprintf(\'<span>%3$s</span>&nbsp;<input type="checkbox" name="status[%1$s]" id="status_%1$s" value="%1$s"%2$s />', $rowData['id_button'], $isChecked, $txt[$rowData['status']], $rowData['status']);
     }
    'class' => 'centertext',
),

Are they correct?

After the upload the Ultimate Menu pages are not shown, but this new error message:
syntax error, unexpected 'if' (T_IF)

The error protocol says this:
Exception: syntax error, unexpected 'if' (T_IF)
line 11


Line 11 is the second here:
Code: [Select]
create_function
    if (!defined('ELK'))
die('No access...');
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7

Re: [ADDON] Ultimate Menu

Reply #82
They look correct, not sure how that create_function got in the top of your file? That’s causing the error.

The \ on the third one just after the sprintf also shouldn’t be there.

Re: [ADDON] Ultimate Menu

Reply #83
I hope I remember to look into this when I am home. Now I need to do some shopping.

Re: [ADDON] Ultimate Menu

Reply #84
I removed the slash and also the "create_function".
Now there's an error message for line 218:
syntax error, unexpected ''class'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'

Line 218 is the penultimate:  'class' => 'centertext',

Code: [Select]
'data' => array (
    function ($rowData ) use ( $txt ) {

    $isChecked = $rowData['status'] === 'inactive' ? '' : ' checked="checked"';
    return sprintf('<span>%3$s</span>&nbsp;<input type="checkbox" name="status[%1$s]" id="status_%1$s" value="%1$s"%2$s />', $rowData['id_button'], $isChecked, $txt[$rowData['status']], $rowData['status']);
    }
    'class' => 'centertext',
),
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7

Re: [ADDON] Ultimate Menu

Reply #85
Think you need a , after the closing }

Sorry I can’t test atm only on my phone until the weekend now.

Re: [ADDON] Ultimate Menu

Reply #86
Yes, it was the missing  ,  .
The error messages are now gone. Thank you!  :)

However, as I have seen, in the ACP in the list of the menu buttons, the entries under "Button Type" and "Button Position" are gone, too. Something like "external link" and "after Forum". That's also now when I create a new link/button.
But the links in the forum menu are working and so that's not bad.
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7

Re: [ADDON] Ultimate Menu

Reply #87
It might be that the $txt isn’t defined as a global until it was called.

Try putting global $txt; at the start of each function ( not the ones you just created , but the existing ones )

It might be showing something in the error log on Elkarte about $txt being undefined if this is the issue.

Re: [ADDON] Ultimate Menu

Reply #88
The error log is empty...
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7

Re: [ADDON] Ultimate Menu

Reply #89
I didn't manage that with the global $txt; . Either I did something wrong while writing or I inserted it in the wrong places. Or both together...
Would you please take another look at it and tell me what exactly I need to insert where or what I have to change?
You can take your time, it's not hurry!

Attached is the current page.
ElkArte version: 1.1.6 / Theme: BeSocial / PHP 7.2.7