Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Comment | File | Size | Author |
---|---|---|---|
#34 | filetransfer-psr0-1323124-34.patch | 38.13 KB | Berdir |
#19 | filetransfer-psr0-1323124-19.patch | 38.17 KB | amateescu |
#19 | interdiff-12.txt | 23.7 KB | amateescu |
#17 | filetransfer-psr0-1323124-17.patch | 65.35 KB | aspilicious |
#12 | filetransfer-psr0-1323124-12.patch | 20.4 KB | amateescu |
Comments
Comment #1
amateescu CreditAttribution: amateescu commentedTrying to get my feet wet in this new PSR-0/namespaces stuff :)
Comment #2
amateescu CreditAttribution: amateescu commentedNote for reviewers: I also fixed a @todo in this patch, namely:
This wasn't converted to PSR-0 because we depend on PHP 5.3 now, so I replaced it with:
... new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS) ...
Now I'm wondering if we should also bring #1382222: Clean up API docs for includes/filetransfer in here, so we don't waste time re-rolling patches that touch exactly the same code.
-5 days to next Drupal core point release.
Comment #3
Crell CreditAttribution: Crell commentedNot a valid docblock. It's missing a proper one-liner.
Someone was watching my Code Smells talk where I call out this docblock as being too vague. :-) Thanks for fleshing it out!
That said, I'd suggest not doing any major doc refactoring at the same time. I even marked the DB doc cleanup as postponed until after the PSR-0-shuffling is done. Both are important, but should be done as separate tasks.
The "FileTransfer" prefix on the interface is no longer necessary. Just ChmodInterface is sufficient.
This isn't really PSR-0 specific, but doing the database updates I've been switching from Exception to RuntimeException as my base exception. It's slightly more applicable, I think. (Both are part of PHP itself.)
Again, this can be called simply FTP. (Or maybe Ftp? No strong preference.)
Same comment as above. :-)
Yeah, same thing here. I'll stop mentioning it now.
-5 days to next Drupal core point release.
Comment #4
sunComment #5
amateescu CreditAttribution: amateescu commentedUpdated patch with the following changes:
FileTransfer
I don't agree with removing the "FileTransfer" prefix on interfaces or classes. Imagine doing a
new FTP();
orDefinition of FTP.
in the @file dockblock (even with a use statement at the top of the file).. we might as well call itnew WTF();
:)Comment #7
amateescu CreditAttribution: amateescu commentedForgot to add the new files :/
Comment #8
Crell CreditAttribution: Crell commentedRe #5: That's actually by design. The FileTransfer prefix is totally redundant with the namespace itself. If you're in a given namespace, you don't need to repeat the class name every time. If you're not, then you have the class listed at the top of the file anyway so you know exactly what it is. The context makes it clear what you mean. Just as in the DB layer, Insert as a class name is self-evident when you are in the Query namespace.
I could see the @file declaration having a full namespace listed? We didn't actually discuss that. Oops. :-)
Comment #9
amateescu CreditAttribution: amateescu commentedI don't really enjoy discussing shed colors, so here's a patch without the FileTransfer prefix :)
Comment #10
amateescu CreditAttribution: amateescu commentedRerolled with the latest namespace standards.
Comment #11
Crell CreditAttribution: Crell commentedMinor nit:
This should be a FQCN. (Fully qualified class name.)
Other than that, this looks good to me on visual inspection. We should probably get confirmation from dww or JacobSingh though before marking it RTBC.
Comment #12
amateescu CreditAttribution: amateescu commentedOops, don't know how that slipped :) I'll try to track down dww or JacobSingh in IRC then..
Comment #13
aspilicious CreditAttribution: aspilicious commentedLet's clean these docs while we are on it. I'm also speaking as an avatar for xjm.
I hope I listed everything...
If you need more information: http://drupal.org/node/1354
You can't use @see in @param, just use see. Or use a better short explanation and move the @see to the bottom of the docblock.
Constructors need a docblock too
Returns
There is no description of the param
Why is "options" on the second line, the first line didn't reach 80 characters yet.
Sounds very cryptical to me. (but that can be just me as I never used this subsystem)
This class doesn't have any docblock?
Constructor needs a docblock
Comment #14
amateescu CreditAttribution: amateescu commentedErm.. no :) I wanted to do this from the start (in #2) but Crell is right, we already have #1382222: Clean up API docs for includes/filetransfer for cleaning up the docs.
Comment #15
xjmEditing my comment to be a bit less knee-jerk. :)
When there are things like missing and unclear function and parameter documentation, even if this documentation predates the patch, I think we should make an effort to make the documentation in lines added or changed is correct and to standard. There's a couple reasons for this:
Comment #16
aspilicious CreditAttribution: aspilicious commentedWorking on the docs now!
Comment #17
aspilicious CreditAttribution: aspilicious commentedProbably not perfect yet, but it's a very good start.
A few TODO's left and I'll ping xjm for a review.
Comment #18
aspilicious CreditAttribution: aspilicious commentedCan we put a use statement in the middle of the file.
(couldn't find the docs for psr-0 code)
Comment #19
amateescu CreditAttribution: amateescu commentedI moved all the clean-up from #1382222: Clean up API docs for includes/filetransfer over here and moved that issue to D7. Interdiff is from #12.
Comment #20
aspilicious CreditAttribution: aspilicious commentedI'm not sure this is correct, Overrides can only be used with functions having the same parameter list and name. These constructors are different. In fact constructors are always a special case. And we have to explain the different parameters.
See: http://drupal.org/node/1354#classes
Same
Comment #21
xjmThanks @amateescu and @aspilicious. I'll try to take a closer look at this later today (I hope).
Comment #22
aspilicious CreditAttribution: aspilicious commentedOk apparantly amateescu made some changes not based on my latest patch.
For example, I had documentation for @throws on many functions.
ps: you referred to the database psr-0 patch somewhere, that one didn't contain any style fixes. I didn't noticed it before it got committed, so it's a bad example to refer to.
Comment #23
Crell CreditAttribution: Crell commentedaspilicious: No. PHP requires that the "namespace" line be the first executable line in the file, and any "use" statements be the next executable lines, then any other code. That's not PSR-0; it's just the PHP compiler. :-)
Comment #24
xjmDatabase was a special case because it was 500k long and large enough to merit a merge. :) This patch is not.
Comment #25
amateescu CreditAttribution: amateescu commentedSince @Crell wants a sign-off from dww or JacobSingh, let's see if they watch their assigned queues. Trying dww first :)
Comment #26
dwwThanks to #1212634: Auto-flag when an issue is assigned to you. as soon as you assign an issue to me it shows up in my tracker, which yes, I watch very closely.
That said, it's 3:15am here, I've got a bunch of deadlines this week, and I don't have the time/energy to review a 40K patch.
Furthermore, I'm -1 on completely re-writing the docs as part of a PSR-0 conversion, but whatever, what's done is done, and #15 makes a good case as to why it should happen. However, it a) makes it harder to backport just the doc fixes to D7 and b) makes it harder to review the PSR-0-ness of this issue. Separate issues for separate changes++.
Anyway, I'm now following this, but having it assigned to me is misleading, since I'm not going to be able to do anything with this until next week at the earliest. If/when my situation changes and I can actually review this for real, I'll assign it back to myself.
Cheers
-Derek
Comment #27
amateescu CreditAttribution: amateescu commentedThanks for the prompt reply Derek.
A note for anyone who wants to do a functional review of this patch, they should look at #12 (which is only 20K), because #19 has only additional doc fixes.
Edit: My comment from #2 should also be taken into consideration when reviewing.
Comment #28
pounard@Crell I'm sorry but I must disagree. You don't type the namespace every now and then (only in use statement in the top of the file), so it may be redundant with the namespace, but it's not an issue. On the contrary, namespaces allows us to put longer class names since the use statements are a useful shortcut. On the case of the FTP class, I might not be unhappy to see it that short, because FTP is FTP, it's straightforward, but your statement is not generally true (on the opposite, it's only true here).
Comment #29
chx CreditAttribution: chx commented#28 we already broke compatibility with Ubuntu LTS (much to my disagreement) just to avoid the need to repeat the namespace in the class name so you are fighting a (very) uphill battle here.
Comment #30
pounardHaving non explicit class names is bad, it forces us to abuse of aliasing or as sun proposed in another issue using relative names. This is insane, it will make the code harder to read and harder to grep, harder to search in it etc etc etc... Why do people always prefer short names to explicit names? This insane, shorter names doesn't make the code better, or more readable, or cool, or nice, or pretty...
Comment #31
Crell CreditAttribution: Crell commentedpounard: Dude, chill. :-) I don't see any confusion with the current class names, and I'd rather avoid redundancy to be consistent with most of the other systems we have. As noted in the Lock issue, though, we should (in a separate thread) revisit our namespace rules with a bit more experience. That said, let's stick with what the rules are for now since there's no screaming confusion the way there was with Lock. We want to rewrite this whole subsystem anyway, remember? :-)
Comment #32
pounardI wanted to make my point: explicit is always better. It's not too late to change, it will be once all subsystems will have been converted because no one will want to rewrite them all.
Comment #33
jhodgdonRE - latest patch - I just reviewed the D7 port of the doc fixups that were applied in #19 above. Probably the same problems apply to this patch:
http://drupal.org/node/1382222#comment-5741162
hmmm. It looks like from that list, it's just items (b) and (d):
b) Constructor for the main FileTransfer class (core/lib/Drupal/Core/FileTransfer/FileTransfer.php)
I think we can just leave this out. Kind of a "duh" moment for me. :)
d)(core/lib/Drupal/Core/FileTransfer/FileTransfer.php)
The description above implies that stripping chroot always happens, but the $strip_chroot param says otherwise.
Should be a quick repatch to figure these out and fix the docs...
Comment #34
BerdirHere is a re-roll that also fixes the issues mentioned in #33.
Comment #35
jhodgdonDoc looks better, thanks.
Comment #36
aspilicious CreditAttribution: aspilicious commentedpushing back to dww see #26
Comment #37
Dries CreditAttribution: Dries commentedI think we should have a better name than 'Local' here and in other places. Too much contextual information is lost here, in my opinion. It might be better to duplicate the words FileTransfer and to go for "FileTransfer/LocalFileTransfer"? Suggestions?
Comment #38
jhodgdon+1 on the idea of making class names more contextual. For instance, someone searching on api.drupal.org would not find "Local" if they search for "FileTransfer", which would be a shame. (At the moment, api.drupal.org does not understand namespaces, which is a separate issue.)
Comment #39
pounardCouldn't agree more.
Comment #40
effulgentsia CreditAttribution: effulgentsia commentedIn #1323082-53: Establish standards for namespace usage [no patch], I suggested "using" up until the subsystem name, so #37 would become
return new FileTransfer\Local($jail);
, but Crell and pounard disliked that idea, and they're both more fluent with namespaces than I am. We also have a similar issue of short final class names in #1460476: Figure out sub-namespaces for DBTNG, establishing precedent for other subsytems., where the #1321540: Convert DBTNG to namespaces; separate Drupal bits patch that went in removed the Query prefix from a bunch of final class names by moving them into a Query namespace, so that in D7 we had QueryAlterableInterface, but in D8 we now have simply AlterableInterface (in a Drupal\Core\Database\Query namespace).I'm not too keen on the idea of repeating information in a class name that already exists in its namespace name, so Drupal\Core\FileTransfer\LocalFileTransfer seems wrong to me. Before we go ahead with that, can people give some more feedback on why #1323082-53: Establish standards for namespace usage [no patch] is bad?
[Edit: never mind. see #42]
Comment #41
jhodgdonThe problem with not having longer class names is that the short class names are no longer meaningful by themselves. I'll comment on the other issue though.
Comment #42
effulgentsia CreditAttribution: effulgentsia commentedIgnore #40. Anyone who wants to provide feedback in the other issue is welcome to, but I now see that Symfony uses redundancy in namespace and class names. For example,
Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage
. So I withdraw my objection toDrupal\Core\FileTransfer\LocalFileTransfer
.[Edit: This was an x-post with #41, but still applies.]
Comment #43
pounardAs jhodgdon says, it's not about not repeating things, it's about readability. If we always or almost always use the
use
statement people will never have to read the repeating information, they will just read plain class names without namespaces in code, class names needs to be explicit.Comment #44
Crell CreditAttribution: Crell commentedI recommend we proceed with the patch as is if that's the only issue, and revise later after #1507828: [policy, no patch] Revised standards for class naming within namespaces since that will likely affect a number of subsystems.
Comment #45
catchCan someone explain why this change is in the patch?
Overall I agree with dww that there's two many changes here all at once to make this reviewable, but on the other hand I'd love to get it in since it's the last class in includes from #1320648: Meta: start converting existing core classes to PSR-0 [policy, no patch]
Comment #46
catchNo, no, I see, we don't need 'file path' any more so it's all redundant, the removed comment explains it.
Derek hasn't come back to this issue, but it's 99% moving code plus bits of docs clean-up, not really refactoring much except the custom autoloader, so I've gone ahead and committed this to 8.x (ask for forgiveness, not permission...).
This is already in the PSR-0 overall change notice, so moving straight to fixed.
Comment #47
dwwGlad y'all sorted it out, and sorry I never had a chance to review/test this. I just hope update manager still works. ;)