Make WordPress Core

Opened 17 months ago

Closed 9 months ago

#63201 closed defect (bug) (fixed)

FTPext Stub

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

Description

Healthiness stub for FTPext

Change History (10)

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


17 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.


17 months ago

#3 @audrasjb
17 months ago

  • Version trunk

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

#4 @SirLouen
17 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
17 months ago

  • Milestone Awaiting Review6.9

#6 @kalpeshh
12 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.


9 months ago

#8 @welcher
9 months ago

  • Keywords commit added

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

#9 @westonruter
9 months ago

  • Owner set to westonruter
  • Status newreviewing

#10 @westonruter
9 months ago

  • Resolutionfixed
  • Status reviewingclosed

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.