Skip to content
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

fopen() and fclose() missing as public methods for Varien_Io_File class #810

Closed
roberto-ebizmarts opened this issue Sep 12, 2019 · 5 comments · Fixed by #811
Closed

fopen() and fclose() missing as public methods for Varien_Io_File class #810

roberto-ebizmarts opened this issue Sep 12, 2019 · 5 comments · Fixed by #811
Labels
bug Component: lib/Varien Relates to lib/Varien

Comments

@roberto-ebizmarts
Copy link
Contributor

roberto-ebizmarts commented Sep 12, 2019

Hi, team.
Congrats for the library Varien_Io_File. It has been useful.
On https://github.com/OpenMage/magento-lts/blob/1.9.4.x/lib/Varien/Io/File.php
many functions helps Magento developers to avoid coding standard notifications about using directly mkdir(), file_exists()...So I have used this library in order to "clean" our project code. And I arrived to the point where I didn't find any function which allow developers replace fopen() and fclose() PHP functions.
And maybe it will be necessary a new method which allows to access the resource returned by the new fopen() function equivalent.
I think this is a need, there is not an equivalent way to access to the returned value for fopen() function. And sometimes, some third party functions/methods use this resource as a param.
Thanks.

@Flyingmana
Copy link
Contributor

Which coding standard is triggering this warnings?
You may take a wrong approach here, if its one to detect possible security issues.

Because the class does not offer a general safeguard as far as I see

roberto-ebizmarts added a commit to roberto-ebizmarts/magento-lts that referenced this issue Sep 12, 2019
Hello. This is just an idea for solving OpenMage#810  closes OpenMage#810
@colinmollenhour
Copy link
Member

I'd actually consider much of this class to be an anti-pattern.. For example the filePutContent method is over-complicating the issue, it should just be:

file_put_contents($path.DS.$filename, $data);

That's just my opinion. We're happy to consider a pull request, but I don't think putting effort into adding new functionality to this class is something we will personally be spending time on. If you want to use an OO approach to filesystem handling I'd suggest looking at PHP "flysystem" which is probably much better maintained and supports also external file systems like S3.

@roberto-ebizmarts
Copy link
Contributor Author

roberto-ebizmarts commented Sep 13, 2019

The coding standard is MEQP1.

In the end, that library uses internally the fopen() method, and offers several common and useful methods. So, why not to add these simple methods?
But, don't worry, it is not a issue. I just was looking for an alternative. If it is not possible, not problem. Is there any library which could allow me to access these methods and all the others for filesystem and files handling? Because the coding standard (MEQP1) doesn't allow the use of fopen() and fclose directly(). I replaced several uses of common directory functions with this Varien_Io_File class. So I was thinking to use the same class and not a third only because these two methods don't have equivalents in Varien_Io_File. Other libraries have some methods and others no. And in this class, there are only two common functions missing.
@colinmollenhour, thanks.
Thanks, @Flyingmana

@colinmollenhour
Copy link
Member

Ahh, I see now your motivation more clearly. If it is the marketplace you are concerned about then you should be asking Magento to patch the official version, but that is futile given that M1 is EOL as far as they are concerned. I'm not opposed to accepting your PR, btw, just offering you some alternatives.

@roberto-ebizmarts
Copy link
Contributor Author

Thanks, @colinmollenhour
Have a nice day.

Flyingmana pushed a commit that referenced this issue Nov 11, 2019
* fopen() and fclose()

Hello. This is just an idea for solving #810  closes #810

* Update File.php

Just adding a getter for _streamHandler class attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Component: lib/Varien Relates to lib/Varien
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants