comparison function is deprecated

Support MB Views comparison function is deprecatedResolved

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #47264
    Tobias HaasTobias Haas
    Participant

    Hey MB Team,
    I discovered this today in the Query Monitor - can you please fix it - thank you very much

    Deprecated
    uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/Extension/CoreExtension.php:940
    uasort()
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/Extension/CoreExtension.php:940
    elightup_twig_sort_filter()
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/Environment.php(358) : eval()'d code:42
    __TwigTemplate_6f2d1548ff5e8e282c5e5fdbd4135f74->doDisplay()
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/Template.php:394
    eLightUp\Twig\Template->displayWithErrorHandling()
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/Template.php:367
    eLightUp\Twig\Template->display()
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/Template.php:379
    eLightUp\Twig\Template->render()
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/TemplateWrapper.php:40
    eLightUp\Twig\TemplateWrapper->render()
    wp-content/plugins/meta-box-aio/vendor/elightup/twig/Twig/Environment.php:277
    eLightUp\Twig\Environment->render()
    wp-content/plugins/meta-box-aio/vendor/meta-box/mb-views/src/Renderer.php:72
    MBViews\Renderer->render()
    wp-content/plugins/meta-box-aio/vendor/meta-box/mb-views/src/Shortcode.php:28
    MBViews\Shortcode->render()
    wp-includes/shortcodes.php:434
    do_shortcode_tag()
    wp-includes/shortcodes.php:434
    preg_replace_callback()
    wp-includes/shortcodes.php:273
    do_shortcode()
    wp-content/themes/bricks/includes/elements/shortcode.php:96
    Bricks\Element_Shortcode->render()
    wp-content/themes/bricks/includes/elements/base.php:2591
    Bricks\Element->init()
    wp-content/themes/bricks/includes/frontend.php:629
    Bricks\Frontend::render_element()
    wp-content/themes/bricks/includes/elements/container.php:929
    Bricks\Element_Container->render()
    wp-content/themes/bricks/includes/elements/base.php:2591
    Bricks\Element->init()
    wp-content/themes/bricks/includes/frontend.php:629
    Bricks\Frontend::render_element()
    wp-content/themes/bricks/includes/frontend.php:770
    Bricks\Frontend::render_data()
    wp-content/themes/bricks/includes/frontend.php:1017
    Bricks\Frontend::render_content()
    wp-content/themes/bricks/page.php:7
    #47276
    PeterPeter
    Moderator

    Hello Tobias,

    Which is the PHP version that you are using? According to the stack trace, the Bricks theme is included in the error message. Can you please also deactivate this theme and check the issue again?

    #47279
    Tobias HaasTobias Haas
    Participant

    PHP 8.3.10
    Bricks 1.12-beta

    #47281
    Tan NguyenTan Nguyen
    Participant

    Dear Tobias,

    Thanks for your information, I have added into a backlog and gonna fix it as soon as I can.

    Cheers!

    #47285
    Tan NguyenTan Nguyen
    Participant

    Dear Tobias,

    I have checked further and see that the call stack ultimately call uasort() function, therefore, the caller should sastifie the uasort(), meaning the 2nd parameter should be numeric value.

    However, since you are using Bricks, it could be from there. As currently we don't have full context right now, can you please send me your input data like field you are using and settings you have saved so I can replicate and fix it if we could do in our end?

    Cheers!

    #47287
    Tobias HaasTobias Haas
    Participant
    {% set group = attribute(site, 'fc-koenigsfeld') %}
    {% set erste_mannschaft = attribute(group, 'erste_mannschaft') %}
    {% set erste_mannschaft = (erste_mannschaft|length > 1) 
                                ? (erste_mannschaft|sort((a, b) => a.date_nextmatch_erste.timestamp > b.date_nextmatch_erste.timestamp)
                                    |filter(v => v.date_nextmatch_erste.timestamp > mb.microtime(true)))
                                : erste_mannschaft %}
    
    {% if erste_mannschaft|length > 0 %}
        {% set erste_mannschaft = erste_mannschaft|first %}
        <p class="fck-next">Nächstes Spiel</p>
        <div class="fck-next-match">
            <div class="fck-team-block">
                <p class="fck-team-name">{{ erste_mannschaft.heimmannschaft_erste.title }}</p>    
                {{ _self.logo(erste_mannschaft.heimmannschaft_erste) }}
            </div>
            <span class="fck-vs-nextgame">vs</span>        
            <div class="fck-team-block">
                <p class="fck-team-name">{{ erste_mannschaft.auswaerts_erste.title }}</p>    
                {{ _self.logo(erste_mannschaft.auswaerts_erste) }}
            </div>
        </div>
        <div class="fck-match-data">
            <div class="fck-match-data__inner">
                <p>// {{ erste_mannschaft.Liga_erste.label }}</p>
                <p>// {{ erste_mannschaft.date_nextmatch_erste.timestamp|date("d.m.Y") }} um {{ erste_mannschaft.date_nextmatch_erste.timestamp|date("H:i") }} Uhr</p>
                <p>// {{ mb.rwmb_meta('adresse_sportplatz', null, erste_mannschaft.heimmannschaft_erste.ID) }}</p>
            </div>
        </div>
    {% else %}
        <div class="fck-match-data">
            <div class="fck-match-data__inner">
               <p style="text-align:center">Aktuell sind keine Spiele geplant...</p>
            </div>
        </div>
    {% endif %}
    
    {% macro logo(post, size = 'medium') %}
        <img class="fck-team-logo" src="{{ post.thumbnail[size].url }}" alt="{{ post.alt }}" title="{{ post.title }}">
    {% endmacro %}

    Is this enought? Lemme know if you need more informations

    #47293
    Tan NguyenTan Nguyen
    Participant

    Dear Tobias,

    I can see you are returning boolean from this expression

    
    sort((a, b) => a.date_nextmatch_erste.timestamp > b.date_nextmatch_erste.timestamp)
    

    Since PHP 8 requires returning numeric value instead, you will need to return -1, 0, 1 respective to the sort data. You can use the spaceship operator like so:

    
    sort((a, b) => a.date_nextmatch_erste.timestamp <=> b.date_nextmatch_erste.timestamp)
    

    Let me know if the issue is resolved.

    #47296
    Tobias HaasTobias Haas
    Participant

    Hey Tan,
    Thank you very much! This fixed the problem.

    #47297
    Tobias HaasTobias Haas
    Participant

    Here's another one

    Deprecated	Creation of dynamic property SWP_Meta_Box_Integration_Updater::$beta is deprecated	
    wp-content/plugins/searchwp-meta-box-integration/vendor/updater.php:46
    SWP_Meta_Box_Integration_Updater->__construct()
    wp-content/plugins/searchwp-meta-box-integration/searchwp-meta-box-integration.php:486
    searchwp_meta_box_integration_update_check()
    wp-includes/class-wp-hook.php:324
    do_action('admin_init')
    wp-admin/admin.php:175
    #47299
    Tobias HaasTobias Haas
    Participant

    nevermind! i ask the SearchWP Team. thanks

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.