Poll

According to w3techs, PHP 5.2+ has a 98.1% market share, and PHP 5.3+ has 63.7%. Which should be the minimal version Wedge can run on?

5.2 -- my host only offers that, pretty please.
2 (9.1%)
5.3 -- using anonymous functions, namespaces or other things should be done ASAP. Wedge is here to stay.
10 (45.5%)
5.4 -- who cares that it's only used by 11%?! I want array shortcuts! And I want to be the only one to use Wedge anyway!
10 (45.5%)
I don't know what my server is running, and/or I have no idea how to have PHP upgrade, and/or am unsure for now.
0 (0%)
Total Members Voted: 22

Auk

  • Can I get a Box?
  • Posts: 64
Re: Minimum PHP version?
« Reply #30, on December 23rd, 2013, 01:10 PM »Last edited on December 23rd, 2013, 02:28 PM
Whoever can not use php 5.3.4+ should be getting a new host.
Quote
5.2 is the current version required by Wedge. PHP 5.2 is great.
^--- I don't find it great. For $reasons.
It should be 5.3. If I were in charge, I would rather this minimal requirement be set to php 5.4

Edit: @Nao, why yew WampServer?!

Nothing is more despicable than respect based on fear.

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Minimum PHP version?
« Reply #31, on December 23rd, 2013, 04:07 PM »
Minimal requirement of 5.4 is a bit overkill, actually. The only 'nice' feature in 5.4 is that they now allow for the JavaScript array notation, i.e. $a = [1, 2, 3];
So this saves code, but you know what..? With Wedge's PHP caching, I can perfectly do it 'à la Wess', use array shortcuts, and then at cache time, replace any 5.4-arrays with 5.3-arrays. That sounds silly, but it's quite easy to do with my current codebase.

While 5.3 had two features that I wanted to use, and that are hard to 'emulate'[1]: closures and namespaces. However, it's not the panacea I thought it was...

- Namespaces are actually quite useless in a SMF codebase, AFAICT. Add 'namespace Wedge' to the top of index.php... Run it. It crashes. To be clear, any functions defined inside index.php are prefixed with Wedge\, and need to be called that way (such as Wedge\loadSource(...)) when called OUTSIDE of the Wedge namespace. That's fine by me... Except for something I didn't know before: if you include/require a file, it will NOT inherit the current namespace. So, the 'solution' is not only to include a namespace Wedge at the top of ALL files that Wedge uses, but also hardcode the Wedge\ prefix into any callback strings, and other things like that. That seems awfully overkill for the use I wanted to do of it (i.e. simplify a few function names while not risking name collisions with other libraries or the main website.)
In the end, I don't think I'll be using that, then. But the good news is, now you can use Laravel next to Wedge, or something... :P

- Closures ARE the panacea for me, for sure, but I've made a few benchmarks, and didn't notice any difference with creation_function(), even though it's supposed to be about 10 times faster. Not a big deal, though -- I spent years complaining that I couldn't use closures, I'm happy enough that I can use them now...! I've already rewritten Profile-Modify.php, it saves 500 bytes of escaped quotes (!!), much easier to debug, and at last code inside these functions is easily findable through a grep.

But PHP 5.4...? I'll probably use array shortcuts, for sure. I'll just backport them to PHP 5.3, and everyone will be happy.
Posted: December 23rd, 2013, 04:04 PM

(Oh, and also: getting rid of create_function() and generally any evals will also make my PHP minifier safer to use.)
 1. Technically, a closure can be emulated pre-5.3, by detecting any function assignments (basically, anything 'function(' that isn't preceded by a bracket or things like that), and then turning the result into an escaped string inside a create_function(). Still, it requires properly handling use() keywords, I don't know if that can be done, AND, let's be clear: upgrading to PHP 5.3 is not ONLY about getting new features, it's also about making some things easier, e.g. PCRE 7.2 is required in Wedge, but up until PHP 5.3, a host could disable PCRE, so that was a problem for me.

Suki

  • Posts: 59
Re: Minimum PHP version?
« Reply #33, on December 30th, 2013, 02:20 AM »
Yeah, 5.3 seems like a perfect choice.

Closures can be used in ways regular anonymous functions can't but it requires a full oop approach for that to happen. The whole new array syntax was just a late response at all the bickering from guys who keep pushing for PHP to become more like python or ruby or any other cool new programming language not based on C principles. It really is just a cosmetic thing that shouldn't have to receive soo much publicity.  I would rather see more useful stuff.

5.4 also has object binding in closures which can be really useful when you work with properties who also are closures themselves (since PHP can't distinguish between a closure property and a plain method) or just when you want to inject some external behavior to some class without messing with it or if you for some reason don't like to use the use() keyword :P

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Minimum PHP version?
« Reply #34, on December 30th, 2013, 02:50 PM »
TBH, I'm not 'familiar' enough with PHP's OOP to be able to tell what a closure is, compared to a lambda function. Closure means so much in different areas (to me, it's Google's equivalent of Packer or UglifyJS, for instance...), I just consider the word 'closure' to mean 'self-enclosed function', and that's it. As for OOP, I know the basics (static vs dynamic, private vs protected vs public, singleton vs real class), but I have no reason to explore it further. I could even have converted more callbacks into lambdas, as I found online benchmarks that said lambdas were 10 times faster than create_function and a bit faster than named functions, but from what I could gather with my own benchmarks, it's actually slower than create_function by a few percents, and much slower than named functions. Why? I don't know... All I know is, if it's only used a couple of times at most in the page flow, I'll put my eggs into a lambda function. If I'm adamant about getting the best performance, then I'll go for a named function. create_function() can go entirely though (I think I've removed them all), because the performance makes no difference, and there's no reason to live with the joke that is an eval with escaped quotes.

5.4's array system is something that bothers me right now. My first thought was, "I want that for PHP", because it's how it's done in JS, and I love JS. However, after converting a few calls, I realized it was probably a bit over-hyped. I can live with doing wetem::add(array('my_layer', 'sidebar', ''), 'my_block') instead of wetem::add(['my_layer', 'sidebar', ''], 'my_block'), I suppose. I may revisit that later, especially if I can get my PHP cache to work flawlessly, but for now... I'll postpone it for later.

MrCat

  • Posts: 14
Re: Minimum PHP version?
« Reply #35, on February 1st, 2014, 09:58 PM »
It's easy to say "get a new host if they don't have 5.3" but that's not practical.
I've been with the same host for years, and I'm happy with them - just that they 'happen' to still have 5.2

Will Wedge not function properly on 5.2?
Is it still worth installing the alpha version?


Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Minimum PHP version?
« Reply #36, on February 1st, 2014, 10:29 PM »
Well, the poll is long over now. The results said I should go for 5.4. I chose 5.3 because it's supported by a more realistic number of hosts.
However 5.3 is not even supported anymore. Let alone 5.2...

Yes it was a hard decision to make. Hence the poll. You could make Wedge work on 5.2 by either using an older commit from github that's 5.2 only, or modifying the current version to revert the 5.3 changes. It'll take you at least a day of work if you're a dev, and it won't be easy for you to update to the new versions.

Drop an email to your host and ask them why they're only offering a version of php that hasn't been patched in 5 or 6 years...

Bunstonious

  • Espada
  • Posts: 204
Re: Minimum PHP version?
« Reply #37, on February 1st, 2014, 10:46 PM »
I would have chosen 5.5 if I were an option.

Bleeding edge or go home ;) jks

I roll my own Ubuntu server in Australia (straya)
Quote from Random Guy
Not putting miles on your Ferrari is like not having sex with your Girlfriend so she'll be more desirable to her next Boyfriend

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Minimum PHP version?
« Reply #38, on February 1st, 2014, 11:31 PM »
I've got access to 5.3 only for now for wedge.org, although I know if I took a separate account on the same host (or if I discussed it with my hosting account owner), I could have 5.4 and 5.5. So, for now, it's 5.3 only for me, but only because Wedge is kindly hosted for free by the aforementioned third-party. ;)

(I'm just sad that this server has been doing great for years, and right when I'm going public, it's starting to show signs of fatigue... -_-)

MultiformeIngegno

  • Posts: 1,337
Re: Minimum PHP version?
« Reply #39, on February 2nd, 2014, 02:37 AM »
I think users running outdated versions oh php don't care about users security and shouldn't deserve wedge. I voted for 5.4 and I'm running 5.5.8..

Bunstonious

  • Espada
  • Posts: 204
Re: Minimum PHP version?
« Reply #40, on February 2nd, 2014, 08:24 AM »
Quote from MultiformeIngegno on February 2nd, 2014, 02:37 AM
I think users running outdated versions oh php don't care about users security and shouldn't deserve wedge. I voted for 5.4 and I'm running 5.5.8..
Agreed, security is important these days. People forget how much we have on the internet.

It may only be a small forum but most likely people use the same email and passwords for important sites.

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Minimum PHP version?
« Reply #41, on February 2nd, 2014, 12:42 PM »
It shouldn't matter that they use the same credentials; stored hashes won't be the same, even on the same software across different installs, because of the extra salt that's added to them. Still, if black hats steal your credentials in a more devious way (such as keylogging), you can't do anything about it, but AFAIK the forum software itself can't be hacked into submission to steal passwords, if anything because password inputs don't allow keylogging from JavaScript events. (They don't... Do they??)

No, the official reason I went for 5.3 is because of security yes. Basically, if your server has 5.2 or less, chances are it hasn't been updated in years, and then it means your Linux server might also be an older version, and Linux vulnerabilities are regularly found and patched; which is also why I prefer to rely on someone hosting my websites rather than having to myself deal with keeping the LAMP software up to date and secure. To me, it's a full-time job.

The non-official reason, of course, is that I wanted to play with lambda functions (and what fun they are!), and wanted to be done with pre-5.3 problems. It's also about comfort for me. In the last SMF patch, there's a whole block of code with complicated regex functions (include one with a nice typo in its name... Serious work, bravissimo), and a mention that this crap should be removed once SMF is made 5.3+ only.

Bunstonious

  • Espada
  • Posts: 204
Re: Minimum PHP version?
« Reply #42, on February 2nd, 2014, 01:32 PM »
Makes sense, I try and keep my server up to date, but I admit it's not the first thing I do each morning.

Which reminds me... brb...

MultiformeIngegno

  • Posts: 1,337
Re: Minimum PHP version?
« Reply #43, on February 2nd, 2014, 01:46 PM »
Quote from Bunstonious on February 2nd, 2014, 01:32 PM
Makes sense, I try and keep my server up to date, but I admit it's not the first thing I do each morning.

Which reminds me... brb...
There's difference between not checking every morning and having an environment 7 years old (php 5.2).

Bunstonious

  • Espada
  • Posts: 204
Re: Minimum PHP version?
« Reply #44, on February 2nd, 2014, 01:47 PM »
lol, I know that's what I was getting at.

Seriously though, I try to update every few months, only had MySQL tonight.