Make WordPress Core

Opened 8 months ago

Closed 5 weeks ago

#63201 closed defect (bug) (fixed)

FTPext Stub

Reported by: sirlouen's profile SirLouen Owned by: westonruter's profile westonruter
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Filesystem API Keywords: dev-feedback has-patch commit
Focuses: docs Cc:

Description

Healthiness stub for FTPext

Change History (10)

This ticket was mentioned in PR #8622 on WordPress/wordpress-develop by @SirLouen.


8 months ago
#1

  • Keywords has-patch added

A simple patch to fix a disturbing type error for stubs

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


8 months ago

#3 @audrasjb
8 months ago

  • Version trunk deleted

"to fix a disturbing type error" could you please add some details about the type error reported?

#4 @SirLouen
8 months ago

@audrasjb as It's just a stubs issue
This file was updated some months ago, according to the new PHP 8.1 standard, to use FTP/Connection, instead of resource.
But someone forgot to update the docs $link type when they introduce the update.
So when you use any type of code parser with anything over PHP 8.1, you will see the code plagued with typing errors like: $this->link is not a resource but a FTP/Connection
I've kept resource for anything below PHP 8.1 compatibility (and because the current $link instantiation is still using the resource mode).

You can check the errors with any parser that use the wordpress stubs, intellisense, phpstan...

#5 @audrasjb
8 months ago

  • Milestone changed from Awaiting Review to 6.9

#6 @kalpeshh
3 months ago

https://www.php.net/manual/en/function.ftp-ssl-connect.php

Returns an FTP\Connection instance on success, or false on failure.

ftp_ssl_connect returns false on ftp connection failure so $link can also be false.

To handle that case we can think of adding

/** @var FTP\Connection|resource|false */

This ticket was mentioned in Slack in #core by welcher. View the logs.


5 weeks ago

#8 @welcher
5 weeks ago

  • Keywords commit added

Reviewed in the 6.9 bug scrub today and this looks ready for commit.

#9 @westonruter
5 weeks ago

  • Owner set to westonruter
  • Status changed from new to reviewing

#10 @westonruter
5 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 61116:

Filesystem API: Update WP_Filesystem_FTPext::$link phpdoc type.

This accounts for when ftp_ssl_connect()/ftp_connect() returns false as well as for when FTP\Connection is returned instead of resource as of PHP 8.1.

Props SirLouen, kalpeshh, audrasjb.
Fixes #63201.

Note: See TracTickets for help on using tickets.