Opened 13 years ago
Closed 11 years ago
#18476 closed enhancement (fixed)
Duplicate code in filesystem classes
Reported by: | kurtpayne | Owned by: | kurtpayne |
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | minor | Version: | 3.2.1 |
Component: | Inline Docs | Keywords: | filesystem has-patch commit |
Focuses: | Cc: |
Description
Each filesystem class extends a base class and most, but not all, include an implementation of chown. I propose a slight refactoring to include a default implementation of chown in the base class and let each subclass override chown when necessary.
Attachments (6)
Change History (20)
#2
follow-up:
↓ 3
@
13 years ago
I noticed this recently. The base class is also missing a number of methods that some or all of the others then define. It would be much better if they listed the method as a point of reference for what the WP_Filesystem API is capable of.
#3
in reply to:
↑ 2
@
13 years ago
Replying to nacin:
I noticed this recently. The base class is also missing a number of methods that some or all of the others then define. It would be much better if they listed the method as a point of reference for what the WP_Filesystem API is capable of.
What if the implementations in the base class were the same as the implementations in the direct access class? This would accomplish the goal of giving a reference implementation for each method. The direct access class would be essentially empty, but open for future extension, and the API would remain intact.
#5
@
12 years ago
As he who wrote the classes in question:
- The Direct class was written first, and thus is the most fleshed out (without thought as to what methods would be supported over FTP)
- The FTP Sockets class was written second
- The FTP Extension class attempts to mimick the Sockets class
- The Base class had any methods common to both FTP libraries thrown into it.
The classes are not exactly standardised, I've wanted to (on many occasions) rip out all the "useless" methods and functionality which core doesn't use, or isn't implemented in all of them (For example, chown() can't be done via FTP, therefor, the abstraction shouldn't have a method for it on any of them).
I like the idea of using the Direct class as the defacto "goto place" for docs, but feel they should all be documented individually, But I don't see the need to have stubs in the baseclass - It's not a PHP5 Interface, and if all subclasses are documented correctly, there's little need for it IMHO
#6
@
11 years ago
I like the idea of using the Direct class as the defacto "goto place" for docs, but feel they should all be documented individually, But I don't see the need to have stubs in the baseclass - It's not a PHP5 Interface, and if all subclasses are documented correctly, there's little need for it IMHO
I retract this statement :)
I like attachment:filesystem2.diff and think it'd be the best place to document the expected behaviour of the subclasses.
#7
@
11 years ago
- Component changed from Filesystem to Inline Docs
- Keywords needs-refresh added; dev-feedback removed
- Milestone changed from Awaiting Review to 3.7
This would go well with the Filesystem and Inline docs cleanups in 3.7.
The patch, although it'd still apply, needs some cleanup for todays docs standards.
#9
@
11 years ago
18476.diff is a first-pass docs cleanup and refresh
Still need clarified parameter and return descriptions for:
::copy(), ::move(), ::delete(), ::exists(), ::is_file(), ::is_dir(), ::is_readable(), ::is_writeable(), ::atime(), ::mtime(), ::size(), ::touch(), ::mkdir(), ::rmdir(), ::dirlist()
Sorry, all class-wp-filesystem*.php classes currently do include a chown implementation. This enhancement converges two of them ftpext and ftpsockets into the base class.