Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PHP 8.2 in local development #103

Open
6 tasks done
bobbingwide opened this issue Sep 13, 2023 · 27 comments
Open
6 tasks done

Support PHP 8.2 in local development #103

bobbingwide opened this issue Sep 13, 2023 · 27 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Sep 13, 2023

PHP 8.2.10 was released on 31 August 2023. See https://www.php.net/releases/8.2/en.php

I'm currently running PHP 8.0 which is out of Active Support but on Security Support until 26 Nov 2023.
See https://www.php.net/supported-versions.php

Requirement

  • Upgrade to PHP 8.2 in my local development environment
  • If necessary install PHP 8.1 as well
  • Enable switching between PHP versions: 8.0, 8.1 and 8.2
  • Test WordPress plugins and themes and fix where necessary.

Proposed solution

@bobbingwide bobbingwide added the enhancement New feature or request label Sep 13, 2023
@bobbingwide bobbingwide self-assigned this Sep 13, 2023
@bobbingwide
Copy link
Owner Author

I updated PHP to v8.2.10, wrote p82.bat to switch to PHP 8.2, ran it and tested php -v. Then I rebooted ( there was a windows update to install ) and tried accessing my local development s.b/bw
I saw four messages.

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in C:\apache\htdocs\bw\bwfunc.inc on line 518

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in C:\apache\htdocs\wordpress\wp-content\plugins\oik\libs\bobbforms.php on line 519

Deprecated: Creation of dynamic property Object_Grouper::$having is deprecated in C:\apache\htdocs\wordpress\wp-content\plugins\wp-top12\libs\class-object-grouper.php on line 99

Deprecated: Creation of dynamic property Object_Grouper::$field_value is deprecated in C:\apache\htdocs\wordpress\wp-content\plugins\wp-top12\libs\class-object-grouper.php on line 164

These appear consistent with the upgrade notes for 8.2

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 14, 2023

When I tried to access s.b/wordpress I got Requirements Not Met

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Please check that the mysqli PHP extension is installed and enabled.

If you are unsure what these terms mean you should probably contact your host. 
If you still need help you can always visit the [WordPress support forums](https://wordpress.org/support/forums/).

Fix

  • Copy php.ini for php80 to php82.

@bobbingwide
Copy link
Owner Author

I was then able to start WordPress. With many more Deprecated messages appearing.
I wonder if these problems are the same with PHP 8.1
Better find out I suppose.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 14, 2023

Proposed solution for PHP 8.1

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 14, 2023

Better find out I suppose.

There were far fewer deprecation messages with PHP 8.1
For s.b/bw there was only one message

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in C:\apache\htdocs\bw\bwfunc.inc on line 518

It looks like I should be updating phpMyAdmin as well.
Current version: 5.1.1, latest stable version: 5.2.1

I installed phpMyAdmin v5.2.1 ( All languages version). It works for PHP 8.0, 8.1 and 8.2

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 14, 2023

Enable switching between PHP versions: 8.0, 8.1 and 8.2

PHP versions 8.0, 8.1 and 8.2 have compatible DLLs for the Apache server.

It's easy to switch between versions

  1. Run the appropriate batch file for the required version of PHP ( p80.bat, p81.bat or p82.bat )
  2. Stop/start the Apache server using ApacheMonitor.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 14, 2023

There are some 3rd party plugins I needed to update, deactivate or delete

Plugin Update to Deactivate / delete
wp-mail-smtp 3.9.0
google site kit 1.109.0
wpseo-news Deactivate; out of date premium plugin
gutenberg-wordpress-source Delete the ancient GitHub repo
deposits-partial-payments-for-woocommerce 1.1.13 Deactivated since 1.1.13 didn't fix the message below
easy-digital-downloads 3.2.5 Note: It was deactivated in s.b/oikcom until this version
Network-posts-extended 7.7.1 Deactivate - latest update 7.7.1 still produced messages with PHP 8.2. OK for 8.1
sg-cachepress 7.4.2

Deprecated: Creation of dynamic property AWCDP_Front_End::$has_payment_plans is deprecated

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 15, 2023

Having got a couple of web pages to run without any Deprecated messages I then tried to run my In Situ PHPUnit tests.
They failed completely with a Fatal error:

Fatal error: Could not check compatibility between PHPUnit\PharIo\Manifest\AuthorCollection::getIterator():
PHPUnit\PharIo\Manifest\AuthorCollectionIterator and IteratorAggregate::getIterator(): Traversable, because class 
PHPUnit\PharIo\Manifest\AuthorCollectionIterator is not available in 
phar://C:/apache/htdocs/phpLibraries/phpunit/phpunit-9.5.5.phar/phar-io-manifest/values/AuthorCollection.php on line 33

Looks like I'll have to update PHPUnit to 10.3.
See https://phpunit.de/getting-started/phpunit-10.html

In case there are changes required to update to PHPUnit 10,
I'll do it via the latest version of PHPUnit 9.

  • Download PHPUnit 9.6.3 to \apache\htdocs\phpLibraries\phpunit\phpunit-9.6.12.phar
  • Change pu.bat and phpunit.bat to point to this version of PHPUnit
  • Test if that works
  • Then try PHPUnit 10.3 Download to \apache\htdocs\phpLibraries\phpunit\phpunit-10.3.4.phar
  • Change pu.bat and phpunit.bat to point to this version of PHPUnit

The tests ran with PHPUnit 9.6.12, with lots of messages and a couple of (as yet) unexplained failures.
but when I updated to PHPUnit 10.3.4 it didn't run at all.

Fatal error: Uncaught Error: Class "PHPUnit\TextUI\Command" not found in C:\apache\htdocs\wordpress\wp-content\plugins\oik-batch\oik-phpunit.php:75
Stack trace:
#0 C:\apache\htdocs\wordpress\wp-content\plugins\oik-batch\oik-phpunit.php(30): oik_phpunit_run_phpunit()
#1 C:\apache\htdocs\wordpress\wp-content\plugins\oik-batch\oik-phpunit.php(81): oik_phpunit_loaded()
#2 {main}
  thrown in C:\apache\htdocs\wordpress\wp-content\plugins\oik-batch\oik-phpunit.php on line 75

It would appear that the class to call has changed. I don't yet know what it is so I reverted to PHP 8.0 and got

C:\apache\htdocs\phpLibraries\phpunit\phpunit-10.3.4.phar
PHPUnit 10.3.4 by Sebastian Bergmann and contributors.

This version of PHPUnit requires PHP >= 8.1.
You are using PHP 8.0.2 (c:\php\php.exe).

With PHP 8.1 the result was the same as PHP 8.2.
For the time being I'll continue testing with PHP 8.2 and PHPUnit 9.6

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 15, 2023

This message suggests I need to update WP-CLI

Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in 
phar://C:/d_drive/dos/wp-cli.phar/vendor/mustache/mustache/src/Mustache/Tokenizer.php on line 110

Currently installed version is WP-CLI 2.5.0. Latest is WP-CLI v2.8.1

I updated WP-CLI and the above message went away
but I got another message

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in 
C:\Users\herb\.wp-cli\packages\vendor\wp-cli\i18n-command\src\MakeJsonCommand.php on line 216

It seems I need to update the i18n-command package.
I couldn't do this directly as the version I had installed was dev-master.
The branch has been changed to dev-main.

During the update I got several Deprecated messages from Symfony

C:\apache\htdocs\wordpress\wp-content\plugins>wp package install wp-cli/i18n-command
Installing package wp-cli/i18n-command (dev-main || dev-master || dev-trunk)
Updating C:\Users\herb\.wp-cli\packages\composer.json to require the package...
Using Composer to install the package...
---
Loading composer repositories with package information
Found 97 package versions referenced in your dependency graph. 29 (30%) were optimized away.
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.
Something's changed, looking at all rules again (pass #1)

Dependency resolution completed in 0.001 seconds
Analyzed 68 packages to resolve dependencies
Analyzed 78 rules to resolve dependencies
Lock file operations: 5 installs, 0 updates, 0 removals
Installs: gettext/languages:2.10.0, eftec/bladeone:3.52, mck89/peast:v1.15.4, gettext/gettext:v4.8.11, wp-cli/i18n-command:dev-main 7d82e67
- Locking eftec/bladeone (3.52)
- Locking gettext/gettext (v4.8.11)
- Locking gettext/languages (2.10.0)
- Locking mck89/peast (v1.15.4)
- Locking wp-cli/i18n-command (dev-main 7d82e67)
Writing lock file
Installing dependencies from lock file
Package operations: 5 installs, 0 updates, 0 removals
Installs: gettext/languages:2.10.0, mck89/peast:v1.15.4, gettext/gettext:v4.8.11, eftec/bladeone:3.52, wp-cli/i18n-command:dev-main 7d82e67

Deprecated: Return type of Symfony\Component\Process\Process::getIterator($flags = 0) should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/process/Process.php on line 567
 - Installing <info>gettext/languages</info> (<comment>2.10.0</comment>)

Deprecated: Return type of Symfony\Component\Finder\Finder::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/finder/Finder.php on line 566

Deprecated: Return type of Symfony\Component\Finder\Finder::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/finder/Finder.php on line 637

Deprecated: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::getChildren() should either be compatible with RecursiveDirectoryIterator::getChildren(): RecursiveDirectoryIterator, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php on line 89

Deprecated: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::rewind() should either be compatible with FilesystemIterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php on line 117

Deprecated: Return type of Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator::current() should either be compatible with FilesystemIterator::current(): SplFileInfo|FilesystemIterator|string, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php on line 65

Deprecated: Return type of Symfony\Component\Finder\Iterator\FilterIterator::rewind() should either be compatible with FilterIterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/finder/Iterator/FilterIterator.php on line 32

Deprecated: Return type of Symfony\Component\Finder\Iterator\DepthRangeFilterIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/d_drive/dos/wp-cli.phar/vendor/symfony/finder/Iterator/DepthRangeFilterIterator.php on line 41
 - Installing <info>mck89/peast</info> (<comment>v1.15.4</comment>)
 - Installing <info>gettext/gettext</info> (<comment>v4.8.11</comment>)
 - Installing <info>eftec/bladeone</info> (<comment>3.52</comment>)
 - Installing <info>wp-cli/i18n-command</info> (<comment>dev-main 7d82e67</comment>)
5 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
2 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
---
Success: Package installed.
C:\apache\htdocs\wordpress\wp-content\plugins>wp --version
WP-CLI 2.8.1

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 16, 2023

Having got the PHPUnit tests to pass in s.b/wordpress for oik and oik-bwtrace I then updated the shared library files in oik-libs and tried running s.b/oikcom.

There were other plugins that needed changing.
oik-widget-cache was causing a problem, as it was caching the Deprecated messages.
To clear these I needed to use Appearance > Widgets and change the affected widget(s) to not Include this widget in the cache.

The oik-todo plugin only existed in s.b/oikcom. It wasn't under Git's version control.
It is now... https://github.com/bobbingwide/oik-todo

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 18, 2023

Possibly upgrade Apache

This wasn't necessary but I did it anyway, upgrading from

Server version: Apache/2.4.37 (Win64)
Apache Lounge VC15 Server built:   Oct 18 2018 17:26:33

to

Server version: Apache/2.4.57 (Win64)
Apache Lounge VS17 Server built:   Aug  2 2023 17:28:16

Process

  • Stop Apache using ApacheMonitor
  • Save the original \Apache24 as \Apache2437
  • Unpack backups-sb\qw\httpd-2.4.57-win64-VS17.zip to \Apache24
  • Copy configuration files, including those for generating the SSL certificates, as required.
    Done by copuing the whole git repo for c:\apache24\conf
  • Restart Apache using ApacheMonitor

Also note that the PHP .dll that's loaded by Apache for PHP 8.2 works for 8.0, 8.1 and 8.2

LoadModule php_module "C:/php/php8apache2_4.dll"

It doesn't need changing when switching between PHP version using the .bat routines p80, p81 and p82.

@bobbingwide
Copy link
Owner Author

I should also update my projects in PhpStorm to tell them I'm using PHP 8.1 or PHP 8.2

@bobbingwide
Copy link
Owner Author

bobbingwide commented Sep 19, 2023

In PHP 8.1's documentation for Deprecations and backward compatibility breaks
the first item is Passing null to non-nullable internal function parameters is deprecated.

This is the reason for messages such as:

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated

Up until now when I changed code to fix this problem I either didn't call the routine when the value was null or changed the value to an empty string ( '' ).
Today, while fixing a problem encountered testing oik-libs, I discovered that it's OK to pass false as the 3rd parameter to str_replace().

Wacky.

I wrote this routine to demonstrate the behaviour.

<?php
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );

not_request( null );
not_request( '' );
not_request( 'A' );
not_request( false );


function not_request( $request ) {
	echo "!{$request}!";
if ( !$request ) {
	echo "Not request. ";
} else {
 echo "Request. ";
} 
 $result = str_replace( 'A', 'B', $request );
 echo "!{$result}!";
 echo PHP_EOL;

}

@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 17, 2023

Messages from s.b/wp55
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in C:\apache\htdocs\wp55\wp-includes\functions.php on line 7241

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in C:\apache\htdocs\wp55\wp-includes\functions.php on line 2187

These seem to come from create-block-theme plugin v1.13.2.

0. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\libs\bwtrace.php:108 0
1. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:293 0
2. bw_trace_error_handler(8192,strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated,C:\apache\htdocs\wp55\wp-includes\functions.php,7241) C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:0 4
3. strpos(null,://) C:\apache\htdocs\wp55\wp-includes\functions.php:7241 2
4. wp_is_stream(null) C:\apache\htdocs\wp55\wp-includes\functions.php:2180 1
5. wp_normalize_path(null) C:\apache\htdocs\wp55\wp-includes\plugin.php:769 1
6. plugin_basename(null) C:\apache\htdocs\wp55\wp-admin\includes\plugin.php:1409 1
7. add_submenu_page(null,Embed Google font in the active theme,Embed Google font in the active theme,edit_theme_options,add-google-font-to-theme-json,array) C:\apache\htdocs\wordpress\wp-content\plugins\create-block-theme\admin\class-manage-fonts.php:41 6
8. create_admin_menu() C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:324 1
9. apply_filters(null,array) C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:348 2
10. do_action(array) C:\apache\htdocs\wp55\wp-includes\plugin.php:517 1
11. do_action(admin_menu,) C:\apache\htdocs\wp55\wp-admin\includes\menu.php:161 2
12. require_once(C:\apache\htdocs\wp55\wp-admin\includes\menu.php) C:\apache\htdocs\wp55\wp-admin\menu.php:417 1
13. require(C:\apache\htdocs\wp55\wp-admin\menu.php) C:\apache\htdocs\wp55\wp-admin\admin.php:158 1
14. require_once(C:\apache\htdocs\wp55\wp-admin\admin.php) C:\apache\htdocs\wp55\wp-admin\index.php:10 1

Updating to v1.13.4 resolves the problem.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 21, 2023

Deprecated message for URL https://s.b/bwcom/top-10-wp-plugins/wp-admin/post-new.php

<b>Deprecated</b>: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in <b>C:\apache\htdocs\bwcom\wp-includes\functions.wp-scripts.php</b> on line <b>133</b><br />

[0] => (integer) 8192
[1] => (string) "Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated"
[2] => (string) "C:\apache\htdocs\bwcom\wp-includes\functions.wp-scripts.php"
[3] => (integer) 133
0. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-lib\libs\bwtrace.php:108 0
1. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:293 0
2. bw_trace_error_handler(8192,stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated,C:\apache\htdocs\bwcom\wp-includes\functions.wp-scripts.php,133) C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:0 4
3. stripos(null,</script>) C:\apache\htdocs\bwcom\wp-includes\functions.wp-scripts.php:133 2
4. wp_add_inline_script(jetpack-blocks-editor,null,before) C:\apache\htdocs\wordpress\wp-content\plugins\jetpack\class.jetpack-gutenberg.php:737 3
5. enqueue_block_editor_assets() C:\apache\htdocs\bwcom\wp-includes\class-wp-hook.php:310 1
6. apply_filters(null,array) C:\apache\htdocs\bwcom\wp-includes\class-wp-hook.php:334 2
7. do_action(array) C:\apache\htdocs\bwcom\wp-includes\plugin.php:517 1
8. do_action(enqueue_block_editor_assets) C:\apache\htdocs\bwcom\wp-admin\edit-form-blocks.php:272 1
9. require(C:\apache\htdocs\bwcom\wp-admin\edit-form-blocks.php) C:\apache\htdocs\bwcom\wp-admin\post-new.php:72 

Looks like we need to update Jetpack from 12.2 to 12.8.1

Also logged was

[21-Nov-2023 11:35:28 UTC] PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\src\presenters\canonical-presenter.php on line 50
 

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 2, 2023

PHP 8.3.0 was released on 23 Nov 2023.
I suppose I should now start supporting PHP 8.3 as well.
New issue raised see #114

See https://www.php.net/releases/8.3/en.php

@bobbingwide
Copy link
Owner Author

Note: PHP 8.1 went out of active support 7 days ago. It still has security support until Nov 2024.
I should update my live sites to PHP 8.2, and skip PHP 8.1

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 7, 2023

This problem occurs in s.b/wp55/thisis, the home page, for PHP 8.1 and above.

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated 
in C:\apache\htdocs\wp55\wp-includes\html-api\class-wp-html-tag-processor.php on line 544

C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php(286:2) bw_trace_error_handler(1) 125 1 2023-12-07T11:30:50+00:00 1.216485 0.042415 cf=wp_head,wpseo_head,wpseo_adjacent_rel_url 29690 93 781 58720256/58720256 256M F=1116 err Array

[0] => (integer) 8192
[1] => (string) "Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated"
[2] => (string) "C:\apache\htdocs\wp55\wp-includes\html-api\class-wp-html-tag-processor.php"
[3] => (integer) 544

@#:0 33 0

0. bw_lazy_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\libs\bwtrace.php:108 0
1. bw_backtrace C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\bwtrace-actions.php:293 0
2. bw_trace_error_handler(8192,strlen(): Passing null to parameter #1 ($string) of type string is deprecated,C:\apache\htdocs\wp55\wp-includes\html-api\class-wp-html-tag-processor.php,544) C:\apache\htdocs\wp55\wp-includes\html-api\class-wp-html-tag-processor.php:544 4
3. next_tag(array) C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\src\integrations\front-end-integration.php:327 1
4. adjacent_rel_url(,prev,object) C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:324 3
5. apply_filters(,array) C:\apache\htdocs\wp55\wp-includes\plugin.php:205 2
6. apply_filters(wpseo_adjacent_rel_url,,prev,object) C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\src\presenters\rel-prev-presenter.php:70 4
7. get C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\src\presenters\abstract-indexable-tag-presenter.php:37 0
8. present C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\src\presenters\rel-prev-presenter.php:39 0
9. present C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\src\integrations\front-end-integration.php:409 0
10. present_head() C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:324 1
11. apply_filters(,array) C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:348 2
12. do_action(array) C:\apache\htdocs\wp55\wp-includes\plugin.php:517 1
13. do_action(wpseo_head) C:\apache\htdocs\wordpress\wp-content\plugins\wordpress-seo\src\integrations\front-end-integration.php:383 1
14. call_wpseo_head() C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:324 1
15. apply_filters(null,array) C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php:348 2
16. do_action(array) C:\apache\htdocs\wp55\wp-includes\plugin.php:517 1
17. do_action(wp_head) C:\apache\htdocs\wp55\wp-includes\general-template.php:3052 1
18. wp_head C:\apache\htdocs\wp55\wp-includes\template-canvas.php:17 0
19. include(C:\apache\htdocs\wp55\wp-includes\template-canvas.php) C:\apache\htdocs\wp55\wp-includes\template-loader.php:106 1
20. require_once(C:\apache\htdocs\wp55\wp-includes\template-loader.php) C:\apache\htdocs\wp55\wp-blog-header.php:19 1
21. require(C:\apache\htdocs\wp55\wp-blog-header.php) C:\apache\htdocs\wp55\index.php:17 1

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 7, 2023

wpseo_adjacent_rel_url is being invoked with parameters

   [0] => (string) ""
    [1] => (string) "prev"
    [2] => Yoast\WP\SEO\Presentations\Indexable_Static_Home_Page_Presentation Object

and is implemented by Yoast\WP\SEO\Integrations\Front_End_Integration::adjacent_rel_url;3

In class Front_End_Integration both $this->next and $this->prev are null.

The page contains a core/query block, which does not inherit the main query block, but neither core/query-pagination-next nor core/query-pagination-previous.

Neither $this->next or $this-prev are initialised to empty strings.

I suggest that the the filter function adjacent_rel_url should be changed to return early when either next or prev are null.

public function adjacent_rel_url( $link, $rel, $presentation = null ) {
		if ( $link === \home_url( '/' ) ) {
			return $link;
		}

		if ( $rel === 'next' || $rel === 'prev' ) {
			if ( null === $this->$rel ) {
				return '';
			}
...

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 7, 2023

The problem occurs for the template part latest-posts,html which is displayed by the front-page.html template of my theme called Thisis.

<!-- wp:query {"queryId":7,"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"exclude","inherit":false},"displayLayout":{"type":"flex","columns":3},"layout":{"type":"flex","columns":3}} -->
<div class="wp-block-query"><!-- wp:post-template -->
    <!-- wp:group {"tagName":"main","style":{"spacing":{"padding":{"top":"30px","right":"30px","bottom":"30px","left":"30px"}}},"layout":{"inherit":false}} -->
    <main class="wp-block-group" style="padding-top:30px;padding-right:30px;padding-bottom:30px;padding-left:30px"><!-- wp:post-title {"isLink":true} /-->

        <!-- wp:post-excerpt {"wordCount":20} /-->

        <!-- wp:post-date /-->

        <!-- wp:post-featured-image /--></main>
    <!-- /wp:group -->
    <!-- /wp:post-template --></div>
<!-- /wp:query -->

@bobbingwide
Copy link
Owner Author

I reproduced the problem creating a new page and the query above.
I raised the issue as Yoast/wordpress-seo#20922

@bobbingwide
Copy link
Owner Author

I raised the issue as Yoast/wordpress-seo#20922

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant