This topic was marked solved by Nao, on September 24th, 2012, 02:40 PM
SMF bug 4913 (convert fopen/fwrite to file_put_contents)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,628
I'm not 100% sure why this is being suggested, but it is certainly shorter and cleaner, though I can't see it being any faster or more efficient in the long run. I'm also not sure if there aren't permissions related issues to deal with.
Posted: February 29th, 2012, 02:27 PM

Note that we wouldn't convert all the cases (only where it's atomic, such that we do fopen/fwrite/fclose in quick succession), because that's faster than doing file_put_contents with appending.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,628
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #1 on April 9th, 2012, 01:57 PM »
I'm thinking about this one again.

The grand plan is that attachments, avatars and media, these places all have write access anyway. Plugins, smileys, etc. won't have that access but will do it via the FTP passthrough (as discussed elsewhere) which means there won't be permissions issues, but also where we won't be using native file operations anyway.

Result is that there's very few places this can actually be done meaningfully, except perhaps as a change to the file cache (since the same flock processing should still be possible)
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,918
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #2 on April 9th, 2012, 02:51 PM »
I wouldn't bother. We already converted most opendir to scandir for instance -- it only makes the code cooler. This is probably a case of simply adopting better functions when writing new code.
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,628
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #3 on April 9th, 2012, 02:57 PM »
Well, I did a cursory search and most of the places that might possibly be candidates fall into my other case anyway...
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,628
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #4 on April 27th, 2012, 10:14 PM »
I did switch over the file cache today while I thought about it because it will solve the problems attached to using fwrite, making it more robust. The rest... *shrug* They're typically not cases for conversion, but I'll leave this open for now in case I can be bothered to go look.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,628
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #5 on September 24th, 2012, 01:22 PM »
I've done a few more, most of the remaining fwrites are socket related, there's a few interesting uses I can't be bothered at this stage to fix, though.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,918
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #6 on September 24th, 2012, 02:41 PM »
Hey, a good opportunity to try that Topic Solved plugin... :lol:
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

live627

  • Talking Head
  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,419
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #7 on September 25th, 2012, 12:43 AM »
Should the green topic solved indicator obey permissions as well? I can see it but not the button...

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,628
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #8 on September 25th, 2012, 01:06 AM »
No, the indicator is deliberately designed to be shown regardless - to let people know it's solved even if they can't mark it solved themselves.

(It's in the plugins repo... :whistle:)
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


live627

  • Talking Head
  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,419
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #9 on September 25th, 2012, 01:56 AM »
Quote
(It's in the plugins repo... :whistle:)
I saw it there, will have to check it out :)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,628
Re: SMF bug 4913 (convert fopen/fwrite to file_put_contents)
« Reply #10 on September 25th, 2012, 02:03 AM »
Quick moderation and, really, the permissions in general haven't been tested out thoroughly, oops. But I'm pretty happy with it (I will, at some point also add a log of unsolved topics in the selected boards, but not today)
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.