[theme-reviewers] fopen - write vs. read
Otto
otto at ottodestruct.com
Sat Jun 25 17:00:12 UTC 2011
On Sat, Jun 25, 2011 at 11:50 AM, Bruce Wampler <brucewampler at gmail.com> wrote:
> All the discussion has been about WRITING files. I don't see that the logic
> applies to reading files. Is using fopen to READ files banned also, and if
> not, does Theme Check know the difference?
fopen is banned, period.
file_get_contents is also banned, but I'm considering taking that back
out now. The main reason I put it in the first place was because of
various pieces of malware that attempted to get in the directory, and
all of them used that function.
Until that happens, you can use the simple file() function to read a
file into memory for now.
> Since this needs to be done, and I find the interface to WP_Filesystem not
> nearly as intuitive as plain old fopen, I will attempt to write a wrapper
> for that that will make the whole process as simple as fopen/fwrite and
> perhaps make this all easier for other theme writers.
You should stop using fopen/fwrite to begin with and use the
file_get_contents and file_put_contents functions. That old-school
fopen/fwrite/fclose paradigm is confusing to newer programmers (many
of whom don't know C and the functions therein), and these contents
wrappers can also use direct memory mapping to file methods, if the
underlying OS supports them.
-Otto
More information about the theme-reviewers
mailing list