WPBuddy / largo

A WordPress framework for news websites. Finely-crafted by INN and expertly-honed and maintained by the technology team at WP Buddy.
http://largo.wpbuddy.co
GNU General Public License v2.0
171 stars 83 forks source link

PHP 8 compatibility #1914

Open benlk opened 1 year ago

benlk commented 1 year ago

Expected Behavior

Largo should work under PHP 8

Actual Behavior

The grapevine tells me that INN members report that Largo is experiencing problems on PHP 8.

https://github.com/INN/Largo-Sample-Child-Theme/issues/20

Steps to Reproduce the Problem

Upgrade a PHP 7.4 site to PHP 8

benlk commented 1 year ago

Fix process:

benlk commented 1 year ago

Bugs noted under PHP 7.4:

Many tests fail under PHP 8 and 7.4:

There was 1 warning:

1) PostTagsTestFunctions::test_largo_post_social_links
assertRegExp() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertMatchesRegularExpression() instead.

--

There were 13 failures:

1) AjaxFunctionsTestFunctions::test_largo_load_more_posts_choose_partial
empty query vars did not result in a determination that the partial type is home
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'home'
+'archive'

/var/www/html/wp-content/themes/largo/tests/inc/test-ajax-functions.php:67

2) PostTemplatesTestFunctions::test_largo_remove_hero_C1
C1
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<h2>Headings</h2>\n
+'<p><img src="http://example.org/wp-content/uploads/2023/01/cat-1-771x510.jpg" alt="1559758083_cef4ef63d2_o" width="771" height="475" class="alignnone size-large wp-image-244" /></p>\n
+<h2>Headings</h2>\n
 <p>Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Sed posuere consectetur est at lobortis. Nulla vitae elit libero, a pharetra augue. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec sed odio dui.</p>'

/var/www/html/wp-content/themes/largo/tests/inc/test-post-templates.php:92

3) PostTemplatesTestFunctions::test_largo_remove_hero_C2
C2
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<h2>Headings</h2>\n
+'<p><img src="http://example.org/wp-content/uploads/2023/01/cat-2-771x510.jpg" alt="1559758083_cef4ef63d2_o" width="771" height="475" class="alignnone size-medium wp-image-246" /></p>\n
+<h2>Headings</h2>\n
 <p>Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Sed posuere consectetur est at lobortis. Nulla vitae elit libero, a pharetra augue. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec sed odio dui.</p>'

/var/www/html/wp-content/themes/largo/tests/inc/test-post-templates.php:133

4) PostTemplatesTestFunctions::test_largo_remove_hero_C3
C3
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<p>foo</p>\n
+'<p><img src="http://example.org/wp-content/uploads/2023/01/cat-3-771x510.jpg" alt="1559758083_cef4ef63d2_o" width="771" height="475" class="alignnone size-large wp-image-248" />foo</p>\n
 <h2>Headings</h2>\n
 <p>Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Sed posuere consectetur est at lobortis. Nulla vitae elit libero, a pharetra augue. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Donec sed odio dui.</p>'

/var/www/html/wp-content/themes/largo/tests/inc/test-post-templates.php:173

5) LargoRelatedTestFunctions::test_popularity_sort
Comparing a term with 3 posts to a term with 4 posts did not return -1, which would indicate that 3 had fewer posts than 4 did. If the difference were greater than 1 post, -1 would still be returned.
Failed asserting that 1 matches expected -1.

/var/www/html/wp-content/themes/largo/tests/inc/test-related-content.php:123

6) LargoRelatedTestFunctions::test_unorganized_series_before
Largo_Related did not return the post it was expected to 
Failed asserting that 257 matches expected 258.

/var/www/html/wp-content/themes/largo/tests/inc/test-related-content.php:171

7) LargoRelatedTestFunctions::test_series_asc
The second post should be higher in post ID than the first
Failed asserting that 265 is greater than 266.

/var/www/html/wp-content/themes/largo/tests/inc/test-related-content.php:238

8) LargoRelatedTestFunctions::test_series_desc
The first post should be the younger post
Failed asserting that 271 matches expected 272.

/var/www/html/wp-content/themes/largo/tests/inc/test-related-content.php:278

9) LargoRelatedTestFunctions::test_series_series_custom
The posts were not returned in the custom order.
Failed asserting that false is true.

/var/www/html/wp-content/themes/largo/tests/inc/test-related-content.php:339

10) LargoUpdateTestAjaxFunctions::test_largo_ajax_update_database_true
Failed asserting that false is true.

/var/www/html/wp-content/themes/largo/tests/inc/test-update.php:525

11) UsersTestFunctions::test_largo_render_user_list
Failed asserting that '<div class="user-list"><div class="author-box row-fluid"><h3 class="widgettitle">About <span class="fn n"><a class="url" href="http://example.org/?author=543" rel="author" title="See all posts by User 0001079">User 0001079</a></span></h3><div class="photo"></div><p>foobar</p></div></div>' matches PCRE pattern "/src/".

/var/www/html/wp-content/themes/largo/tests/inc/test-users.php:136

12) UsersTestFunctions::test_more_profile_info
Not all inputs that should have been checked were.
Failed asserting that 1 matches expected 2.

/var/www/html/wp-content/themes/largo/tests/inc/test-users.php:190

13) UsersTestFunctions::test_save_more_profile_info
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'on'
+''

/var/www/html/wp-content/themes/largo/tests/inc/test-users.php:204

However, the frontend continues to display without error.