When scanning Drupal for problems I found that there were several places in the Updater Core library that referred to FileTransferInterface. With a little research I was able to discover that FileTransferInterface doesn't exist in Drupal. However, an abstract FileTransfer object does exist in the FileTransfer folder. Many of the objects that extend FileTransfer also implement a ChmodInterface. So maybe there was an interface that used to exist that was renamed to be called ChmodInterface.

Proposed fix

Find out if we can replace every call to FileTransferInterface to ChmodInterface and if not consider using FileTransfer instead.

Comments

jhodgdon’s picture

in core/modules/update/update.authorize.inc:

 * @param string $updater_name
 *   The name of the Drupal\Core\Updater\Updater class to use for installing
 *   this project.
  * @param FileTransfer $filetransfer
 *   The FileTransfer object to use for performing this operation.
 * @param array $context
 *   Reference to an array used for Batch API storage.
 */
function update_authorize_batch_copy_project($project, $updater_name, $local_url, $filetransfer, &$context) {
...
  $updater = new $updater_name($local_url);

  try {
    if ($updater->isInstalled()) {
      // This is an update.
      $tasks = $updater->update($filetransfer);
    }
    else {
      $tasks = $updater->install($filetransfer);
    }
  }
 

So it appears that the I think only user of this class is declaring it needs a FileTransfer object as input when it calls update() or install().

For now, I think the thing to do on Updater is to just use the FileTransfer class instead of the nonexistent interface. And perhaps file a separate issue that there should be an interface? FileTransfer is currently an abstract class that does not extend any interfaces, and that is where the methods that the Updater class is actually using are defined. ChmodInterface does not have all of these methods, so using it in this case would be incorrect.

Or, we could change this issue to non-documentation and make the issue be that there *should* be a FileTransfer interface (it seems like there should be an interface and not just an abstract class for this?).

jhodgdon’s picture

Component: documentation » base system
Issue summary: View changes
Issue tags: +Novice

This issue is still valid. However, FileTransferInterface is used in the code and not just docs, so moving to the Base System component.

Should be a good Novice issue: change all mentions of FileTransferInterface in Core to say FileTransfer instead.

drubb’s picture

Status: Active » Needs review
Issue tags: +drupaldevdays
StatusFileSize
new3.78 KB

Here 's a first patch just changing all references from FileTransferInterface (old) to FileTransfer (new).

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Change looks right to me. There are other problems in the docs and some @todos in this code, but they are out of scope for this issue. That code just is kind of a mess...

Thanks!

Not sure why the test bot is not firing on this one... I would not suggest committing it until it has turned green...

Oh, the file was set to Hidden. I'll unhide it and hopefully the test bot will agree that it's a good patch.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 3: rename-filetransferinterface-2121863.patch, failed testing.

Status: Needs work » Needs review
googletorp’s picture

Status: Needs review » Reviewed & tested by the community

The patch should pass, if pass RTCB.

xjm’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs followup

Thanks @jhodgdon and @drubb.

+++ b/core/lib/Drupal/Core/Updater/Updater.php
@@ -9,7 +9,7 @@
-use Drupal\Core\FileTransfer\FileTransferInterface;
+use Drupal\Core\FileTransfer\FileTransfer;

@@ -336,7 +336,7 @@ public function makeWorldReadable(&$filetransfer, $path, $recursive = TRUE) {
    *
    * @todo Not implemented.
    */
-  public function makeBackup(FileTransferInterface $filetransfer, $from, $to) {
+  public function makeBackup(FileTransfer $filetransfer, $from, $to) {

So the fact that we have this use statement referring to an interface that doesn't exist could mean either that the use statement was unused, or that code using it was untested.

I looked through Updater.php and the only non-documentation use is in makeBackup()... which has a @todo that it is not implemented, without a reference to an existing issue, and yet the method is called in Updater::update():


      // Take a Backup.
      if ($args['make_backup']) {
        $this->makeBackup($filetransfer, $args['install_dir'], $args['backup_dir']);
      }

So that is clearly an untested code path. I agree with @jhodgdon that fixing that is not in scope here, but before we commit this patch, can we get a followup issue to fix the broken code path? Edit: First we should check for an existing issue. In either case we should reference it here.

Thanks!

googletorp’s picture

StatusFileSize
new3.8 KB

I've taken patch from #3 and added the reference to the newly created issue, regarding the implementation of makeBackup #2474355: \Drupal\Core\Updater\Updater::makeBackup should probably be removed, and the code path that calls it is broken.

@xjm This makes this RTBC right?

googletorp’s picture

Issue tags: -Needs followup
jhodgdon’s picture

An interdiff file would have been helpful here -- next time! :)

Anyway, yes thanks for filing #2474355: \Drupal\Core\Updater\Updater::makeBackup should probably be removed, and the code path that calls it is broken (adding as related) and the new patch is RTBC again.

xjm’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @googletorp, that works!

I noticed also that the inline mentions of the class name were missing the leading slash (also a problem in HEAD), and that the one-line summary for UpdaterFileTransferException is two lines instead. Out of scope here, but we could add another followup issue for that as well.

This issue only changes documentation, so per https://www.drupal.org/core/beta-changes, this can be completed any time during the Drupal 8 beta phase. Committed and pushed to 8.0.x

  • xjm committed e39a328 on 8.0.x
    Issue #2121863 by googletorp, drubb, jhodgdon: There is no...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.