• Hi there,

    the following warnings are present in logs after updating to php8.1.

    PHP Warning:  Undefined variable $q in .../accelerated-mobile-pages/templates/design-manager/design-1/archive.php on line 156
    PHP Warning:  Attempt to read property "max_num_pages" on null in .../accelerated-mobile-pages/templates/design-manager/design-1/archive.php on line 156

    Here is a quick fix to check whether $q was set prior to access its properties.

    --- archive.org.php     2022-10-11 09:41:26.222042154 +0200
    +++ archive.php 2022-10-11 09:43:00.087727714 +0200
    @@ -153,7 +153,7 @@
                        <div class="amp-wp-content pagination-holder">
    
                            <div id="pagination">
    -                               <?php if ( get_next_posts_link('next', $q->max_num_pages) ){ ?><div class="next"><?php echo apply_filters('ampforwp_next_posts_link', get_next_posts_link( ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next' ).'&raquo;', 0), $paged ) ?></div><?php }?>
    +                               <?php if ( isset($q) && get_next_posts_link('next', $q->max_num_pages) ){ ?><div class="next"><?php echo apply_filters('ampforwp_next_posts_link', get_next_posts_link( ampforwp_translation($redux_builder_amp['amp-translator-next-text'], 'Next' ).'&raquo;', 0), $paged ) ?></div><?php }?>
                                    <?php if ( get_previous_posts_link() ){ ?><div class="prev"><?php echo apply_filters( 'ampforwp_previous_posts_link', get_previous_posts_link( '&laquo; '. ampforwp_translation($redux_builder_amp['amp-translator-previous-text'], 'Previous' )), $paged ); ?></div><?php }?>
                                <div class="clearfix"></div>
                            </div>
    

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Sorry for the inconvenience. We will check this scenario on our end and get back to you immediately.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Sorry for the delay in getting back to you. We tried to check this error log but didn’t get this error. Can you please let me know, on which log file you are getting these errors? Can you show me once? So that we will check the same and get back to you immediately.

    Thread Starter Matthieu-P. Schapranow

    (@theschappy)

    Hi @ahmedkaludi,

    I am running WordPress 6.0.2 on PHP8.1 (FPM); the warnings occur in the php.log. I have not investigated why the variable $q is not set properly –– if this is for a specific page or subset of pages. PHP8 became more sticky with regards to the use of undefined variables, so it is the best to check for it before use.

    Best,

    Matthieu

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    We have checked this at our end but it’s not recurring on our end. Can you please provide some more info to replicate the issue on our end? So that we will check the issue and get back to you with the fix.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Undefined variable $q + attempt to read property “max_num_pages” in design-1’ is closed to new replies.