Page MenuHomePhorge

Cannot upload new mockups via Pholio
Closed, ResolvedPublic

Description

The official Phabricator repo received a few more updates this year. I believe an update in May broke Pholio on our Phabricator installation, that automatically self-updates based on the latest stable on Github.

Trying to save a new Pholio post results in the following error:

Illegal offset type in isset or empty at [PhutilErrorHandler.php:261]
Stack trace:
PhutilErrorHandler::handleError called at [/srv/www/phabricator/src/applications/pholio/editor/PholioMockEditor.php:212]
PholioMockEditor::loadPholioImage called at [/srv/www/phabricator/src/applications/pholio/xaction/PholioImageFileTransaction.php:114]
PholioImageFileTransaction::extractFilePHIDs called at [/srv/www/phabricator/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:4414]
PhabricatorApplicationTransactionEditor::extractFilePHIDs called at [/srv/www/phabricator/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:2313]
PhabricatorApplicationTransactionEditor::newFileTransaction called at [/srv/www/phabricator/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:2244]
PhabricatorApplicationTransactionEditor::expandSupportTransactions called at [/srv/www/phabricator/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:1222]
PhabricatorApplicationTransactionEditor::applyTransactions called at [/srv/www/phabricator/src/applications/pholio/controller/PholioMockEditController.php:214]
PholioMockEditController::handleRequest called at [/srv/www/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:284]
phlog called at [/srv/www/phabricator/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable called at [/srv/www/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:751]
AphrontApplicationConfiguration::handleThrowable called at [/srv/www/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:296]
AphrontApplicationConfiguration::processRequest called at [/srv/www/phabricator.ravo.io/phabricator/src/aphront/configuration/AphrontApplicationConfiguration.php:204]
AphrontApplicationConfiguration::runHTTPRequest called at [/srv/www/phabricator/webroot/index.php:35]

I just saw that you merged those newer changes into your fork recently, so I wonder if you are aware of that bug, and whether it's possible to fix it.

Event Timeline

I'll see if I can reproduce this error.

I'm unable to reproduce this issue, after trying on multiple installs. I'm going to release this for someone else to take a try.

Small update: I just migrated our Phabricator installation to Phorge following the instructions in Update From Phabricator. The migration worked, but we still cannot upload new mockups.

I added some debug output to the affected line of code that causes the error message in PholioMockEditor.php on line 212:

public function loadPholioImage($object, $phid) {
  print_r($phid);

  if (!isset($this->images[$phid])) {

The $phid argument is indeed an array of image upload PHID strings:

Array
(
    [0] => PHID-PIMG-2pxae7j2fnbubgpcorxw
)

The caller PholioImageFileTransaction.php is looping over an array of arrays of strings. I also added some debug log output there:

public function extractFilePHIDs($object, $value) {
  $editor = $this->getEditor();

  // NOTE: This method is a little weird (and includes ALL the file PHIDs,
  // including old file PHIDs) because we currently don't have a storage
  // object when called. This might change at some point.

  $new_phids = $value;

  $file_phids = array();

  print_r($value);

The $value argument that is being iterated in a foreach loop shows up as follows:

Array
(
    [+] => Array
        (
            [0] => PHID-PIMG-m5pqg3eec46uvzw6uynm
        )

)

As a bandaid I patched the extractFilePHIDs method in PholioImageFileTransaction.php by adding a nested foreach loop as follows:

foreach ($new_phids as $phids) {
  foreach ($phids as $phid) {
    $file_phids[] = $editor->loadPholioImage($object, $phid)
      ->getFilePHID();
  }
}

This fixes the problem on our installation for now, but I would like to avoid having to manage any local changes

In addition to the above, it seems that commit d017f3f21021 is what broke this. And adjustTransactionValues is what changes the xaction from

Array
(
    [+] => Array
        (
            [0] => PHID-PIMG-m5pqg3eec46uvzw6uynm
        )

)

to

Array
(
    [0] => PHID-PIMG-2pxae7j2fnbubgpcorxw
)

It seems that commit calls extractFilePHIDs before adjustTransactionValues.

As a bandaid I patched the extractFilePHIDs method in PholioImageFileTransaction.php by adding a nested foreach loop as follows:

foreach ($new_phids as $phids) {
  foreach ($phids as $phid) {
    $file_phids[] = $editor->loadPholioImage($object, $phid)
      ->getFilePHID();
  }
}

This fixes the problem on our installation for now, but I would like to avoid having to manage any local changes

Would you be willing to create a revision so we can put that fix into upstream? If you're not sure how, or need some help, feel free to ping me!

As a bandaid I patched the extractFilePHIDs method in PholioImageFileTransaction.php by adding a nested foreach loop as follows:

foreach ($new_phids as $phids) {
  foreach ($phids as $phid) {
    $file_phids[] = $editor->loadPholioImage($object, $phid)
      ->getFilePHID();
  }
}

This fixes the problem on our installation for now, but I would like to avoid having to manage any local changes

Would you be willing to create a revision so we can put that fix into upstream? If you're not sure how, or need some help, feel free to ping me!

I just submitted a patch and ran into issues with running unit tests. It seems like the tests expect me to set up a MySQL database. I submitted the patch with arc diff --nounit if that's OK with you

As a bandaid I patched the extractFilePHIDs method in PholioImageFileTransaction.php by adding a nested foreach loop as follows:

foreach ($new_phids as $phids) {
  foreach ($phids as $phid) {
    $file_phids[] = $editor->loadPholioImage($object, $phid)
      ->getFilePHID();
  }
}

This fixes the problem on our installation for now, but I would like to avoid having to manage any local changes

Would you be willing to create a revision so we can put that fix into upstream? If you're not sure how, or need some help, feel free to ping me!

I just submitted a patch and ran into issues with running unit tests. It seems like the tests expect me to set up a MySQL database. I submitted the patch with arc diff --nounit if that's OK with you

Sure, no problem! I'll run the tests on my machine.