problems with php version 8.01
-
I’m building a website on localhost, used ajax-load-more plugin and it worked just fine.
recently I had to upgrade the PHP version to 8.01.
After the upgrade the plugin doesn’t work.The posts doesn’t load at all, I scroll down and I can see the loading gif but no posts are loaded.
Is there a known problem with this version of PHP?
is there a fix?Thanks
IshaiThe page I need help with: [log in to see the link]
-
Hi @ishchai I haven’t had reports of issues with 8.1.
Is there a specific error you are seeing in the error log?
Also, could you share a public link?Dear Dcooney,
The plugin works on a website of my client, since it doesn’t work with the new PHP version I downgraded the PHP version on the server so now it works fine there.
So the reason the plugin didn’t work is for sure the new PHP version.
That’s also why it won’t help to give you the link because now it runs on the old PHP version and there’s no issue.
Still, I need to use the newer version on my server so I need to find out the source of the problem.When I check it on localhost that's the error I get on the console: Error: Error: ajax-load-more.min.js?ver=5.5.4.1:6 Request failed with status code 500 at t.exports (ajax-load-more.min.js?ver=5.5.4.1:6:62719) at t.exports (ajax-load-more.min.js?ver=5.5.4.1:6:90936) at XMLHttpRequest.x (ajax-load-more.min.js?ver=5.5.4.1:6:61109) ajax-load-more.min.js?ver=5.5.4.1:6 Error Msg: Request failed with status code 500 ajax-load-more.min.js?ver=5.5.4.1:6 ALM Error started in adminajax ajax-load-more.min.js?ver=5.5.4.1:6 ALM ErrorIf you don’t know of any issues with the new version, I guess it might be some code inside the Repeater Template that doesn’t work on the new PHP version.
I would love to know your thought about it
Thanks
Ishai@ishchai Can you check the server error logs not the browser console?
FROM THE APACHE ERROR.LOG:
[Tue Aug 30 19:01:07.240775 2022] [php:warn] [pid 9440:tid 1892] [client ::1:56677] PHP Warning: Undefined variable $post in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php on line 4, referer: http://localhost:8080/atikot/
[Tue Aug 30 19:01:07.240775 2022] [php:warn] [pid 9440:tid 1892] [client ::1:56677] PHP Warning: Attempt to read property “ID” on null in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php on line 4, referer: http://localhost:8080/atikot/
[Tue Aug 30 19:01:07.240775 2022] [php:warn] [pid 9440:tid 1892] [client ::1:56677] PHP Warning: Undefined variable $post in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php on line 5, referer: http://localhost:8080/atikot/
[Tue Aug 30 19:01:07.240775 2022] [php:warn] [pid 9440:tid 1892] [client ::1:56677] PHP Warning: Attempt to read property “ID” on null in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php on line 5, referer: http://localhost:8080/atikot/
[Tue Aug 30 19:01:07.247758 2022] [php:error] [pid 9440:tid 1892] [client ::1:56677] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php:97\nStack trace:\n#0 C:\\xampp\\htdocs\\atikot\\wp-content\\plugins\\ajax-load-more\\core\\functions.php(95): include()\n#1 C:\\xampp\\htdocs\\atikot\\wp-content\\plugins\\ajax-load-more\\ajax-load-more.php(686): alm_loop(‘default’, ‘default’, ‘null’, 8, 1, 1, 1, Array, false)\n#2 C:\\xampp\\htdocs\\atikot\\wp-includes\\class-wp-hook.php(307): AjaxLoadMore->alm_query_posts(”)\n#3 C:\\xampp\\htdocs\\atikot\\wp-includes\\class-wp-hook.php(331): WP_Hook->apply_filters(”, Array)\n#4 C:\\xampp\\htdocs\\atikot\\wp-includes\\plugin.php(476): WP_Hook->do_action(Array)\n#5 C:\\xampp\\htdocs\\atikot\\wp-admin\\admin-ajax.php(187): do_action(‘wp_ajax_alm_get…’)\n#6 {main}\n thrown in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php on line 97, referer: http://localhost:8080/atikot/Fixed!
The problem was the function count in the Repeater Template..
For some reason, it didn’t work on the new PHP version.Replaced $numTags = count($posttags);
with $numTags = is_array($posttags) ? count($posttags) : 0 ;Works ok now.
Nice find!
Still something very strange…
I have these two lines in the Repeater Template code:
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), ‘single-post-thumbnail’ ); ?>There are no error on the browser console and the thumbnail images are displayed.
Still, in the Apache error log I find this:PHP Warning: Undefined variable $post in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php on line 5, referer: http://localhost:8080/atikot/%d7%9b%d7%9c-%d7%94%d7%9b%d7%aa%d7%91%d7%95%d7%aa/ [Tue Aug 30 19:54:08.505761 2022] [php:warn] [pid 9440:tid 1880] [client ::1:58758] PHP Warning: Attempt to read property "ID" on null in C:\\xampp\\htdocs\\atikot\\wp-content\\uploads\\alm_templates\\default.php on line 5, referer: http://localhost:8080/atikot/%d7%9b%d7%9c-%d7%94%d7%9b%d7%aa%d7%91%d7%95%d7%aa/If I add the condition isset($post) the images are not displayed and I get many other error on the Apache log…
At the top of your template add
global $post;Thanks, that fixed it.. no more errors!!
Thank you so much and have a great day! 🙂
The topic ‘problems with php version 8.01’ is closed to new replies.