Skip to content

10058: Tablerate->getCsvFile() fails with non-default PHP upload_tmp_dir #12275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

RomaKis
Copy link
Contributor

@RomaKis RomaKis commented Nov 15, 2017

Description

Now path for upload_tmp_dir can be any.
2.3 pr: #12376

Fixed Issues (if relevant)

  1. Tablerate->getCsvFile() fails with non-default PHP upload_tmp_dir #10058: Tablerate->getCsvFile() fails with non-default PHP upload_tmp_dir

Manual testing scenarios

  1. Make a new directory for uploads, eg mkdir -p /var/lib/php/uploads && chmod 1777 /var/lib/php/uploads
  2. Set PHP upload_tmp_dir to this directory. eg, add upload_tmp_dir = /var/lib/php/uploads to /etc/php.ini
  3. Login to Magento Admin
  4. Go to Stores > Configuration > Sales > Shipping Methods
  5. Select Table Rates, and enable
  6. Click "Import"
  7. Choose a file, click save.

Expected result
Table rates are updated

Actual result
Receive an error, eg The file “/tmp/var/lib/php/uploads/phphEpJe5” doesn’t exist

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team magento-engcom-team added bugfix Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Nov 15, 2017
@dmanners dmanners self-assigned this Nov 15, 2017
@dmanners dmanners added this to the November 2017 milestone Nov 15, 2017
* @return \Magento\Framework\Filesystem\Directory\ReadInterface
*
*/
public function getDirectoryReadByPath($path, $driverCode = DriverPool::FILE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we cannot add new public methods to this class as it has been marked with @api would it work if we called getDirectoryRead here instead of making the new call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmanners, no it wouldn't. It checks it suggested path is one of the /Magento/Framework/App/Filesystem/DirectoryList::getDefaultConfig().
And what if I'll create the pr with a same code to 2.3?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ok, If that is not possible then I would suggest that 2.3 would be fine for this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmanners,link for the pr to 2.3: #12376.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about creating a new class (something like \Magento\Framework\FilesystemV2) and using that one instead (by injecting it as an extra optional parameter at Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate::__construct()) and deprecating the old one? Would that be deemed acceptable in such a case?

@dmanners
Copy link
Contributor

@RomaKis is is possible to still use getDirectoryRead instead of adding the new method? For version 2.2 we cannot add a new method to that class as it has been marked with the @api notation. Thanks

@dmanners
Copy link
Contributor

@RomaKis I will close this PR as we now have a pr to 2.3 as the changes required a new function that could not be back ported. If you can think of a may to make it work for 2.2 then please feel free to open a new PR for that branch.

@dmanners dmanners closed this Nov 21, 2017
@RomaKis
Copy link
Contributor Author

RomaKis commented Nov 21, 2017

@dmanners, but why can't we backport it to 2.2? Seems like it doesn't break any backward compatibility http://devdocs.magento.com/guides/v2.0/contributor-guide/backward-compatible-development/.

@dmanners
Copy link
Contributor

@RomaKis adding a public method to a class marked with the @api notation is not allowed in patch release such as the next 2.2. This is fine going to 2.3 as it is but will need to be re-worked if we want to produce this fix for the 2.1 or 2.2 versions. http://devdocs.magento.com/guides/v2.2/contributor-guide/backward-compatible-development/index.html#introduction-of-a-method-to-a-class-or-interface

@RomaKis
Copy link
Contributor Author

RomaKis commented Nov 21, 2017

@dmanners, ok, thanks for clarification :)

@dmanners
Copy link
Contributor

@RomaKis no problem. If you can see a way of getting this change into 2.2 and 2.1 without breaking BC then I would be happy to see a PR for it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Progress: needs update Release Line: 2.2 Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants