Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Nao
10051
Features / Re: New revs
« on November 12th, 2010, 05:55 PM »
Hmm yeah I didn't notice that but if you're saying so it's probably right!
I made a mistake anyway when I complained about reset_pass, I think that it's never passed as a ref...
10052
Plugins / Re: Plugin hooks
« on November 12th, 2010, 05:44 PM »
Quote from Arantor on November 12th, 2010, 05:37 PM
Neither is integrate_eggnog but hey, who's counting?
Except that 'integrate_magic_quotes' REALLY is tested against in the source code... :^^;:
Quote
magic_quotes shouldn't really be needed though (only for those really weird CMSes that do strange mystic things when magic quotes is enabled)
But from the name of it, it should be a hook, shouldn't it...? Well, it isn't. It's just a hidden setting that just happens to have the same name as a hook function. Uh.

Okay, I'm done, up to you now...
I'm reposting the changelog here for future readers' convenience, since the New Revs topic isn't public yet.

rev 252

* Renaming hook-related functions and variables. Integration functions become call/add/remove_hook for simplicity reasons. Hooks are renamed from $modSettings['integrate_something'] to $modSettings['hooks']['something'], and are now proper arrays. Finally, SMF_INTEGRATION_SETTINGS is renamed to WEDGE_HOOK_SETTINGS. So what? (index.php, Activate.php, Admin.php, Class-Editor.php, Errors.php, Load.php, LogInOut.php, ManageMembers.php, Profile-Actions.php, Profile-Modify.php, Profile.php, Register.php, Reminder.php, Security.php, Subs-Auth.php, Subs-Members.php, Subs-Post.php, Subs.php, Who.php, Display and MessageIndex templates)
* Made sure that the error message can be tampered with by the output_error hook. Otherwise, it's relatively useless. (Errors.php)
* Given that the outgoing_email hook has permission to tamper with e-mail data, personal_message and create_topic hooks should be able to play around with their data, too. Same with $data in the change_member_data hook in updateMemberData. (Subs.php, Subs-Post.php)
Posted: November 12th, 2010, 05:43 PM

Do you think 64KB (the max variable length (TEXT) in wedge_settings) will be enough to store all possible hooks...?
I think so, but what if a forum is modded to death...? I guess it'd stop functioning quickly, anyway. Hmm.
The only issue with my own implementation is that it requires unserializing all entries, while SMF's version explodes the strings only when needed. SMF's may be slightly faster, but I don't know if it's worth filling the settings table with hook names...
10053
Features / Re: New revs
« on November 12th, 2010, 05:40 PM »
rev 252

! In case guests can post to topics, make sure they return to the topic after they posted. (install.sql)
* Renaming hook-related functions and variables. Integration functions become call/add/remove_hook for simplicity reasons. Hooks are renamed from $modSettings['integrate_something'] to $modSettings['hooks']['something'], and are now proper arrays. Finally, SMF_INTEGRATION_SETTINGS is renamed to WEDGE_HOOK_SETTINGS. So what? (index.php, Activate.php, Admin.php, Class-Editor.php, Errors.php, Load.php, LogInOut.php, ManageMembers.php, Profile-Actions.php, Profile-Modify.php, Profile.php, Register.php, Reminder.php, Security.php, Subs-Auth.php, Subs-Members.php, Subs-Post.php, Subs.php, Who.php, Display and MessageIndex templates)
* Made sure that the error message can be tampered with by the output_error hook. Otherwise, it's relatively useless. (Errors.php)
* Given that the outgoing_email hook has permission to tamper with e-mail data, personal_message and create_topic hooks should be able to play around with their data, too. Same with $data in the change_member_data hook in updateMemberData. (Subs.php, Subs-Post.php)
10054
Plugins / Re: Plugin hooks
« on November 12th, 2010, 04:58 PM »
Quote from Arantor on November 12th, 2010, 03:46 PM
There are instances where arrays are stored in $modSettings. None of them are consistent (e.g. the signature settings is a comma-separated value list, the censored words good/bad lists are newline-separated items, as are news items)
Hmm... More afterthoughts, eh? ;)
Quote
Storing an array is fine, but I personally wouldn't make it automatic, because you only have to unserialise it again later - and unless you're going to maintain a list of those things, you won't know what to unserialise en masse at the start.
Yeah, all right, I just unserialize hooks from reloadSettings (in the precache code), and then I serialize them again in add_hook(). I'm making sure to save the hooks before calling updateSettings, because otherwise $modSettings['hooks'] would suddenly be serialized. (I suppose it's faster to save the value beforehand rather than unserializing it afterwards.)

Other issues: 'buffer', 'pre_include' are strange beasts... They're undocumented (except by you!), but they're pretty necessary, at least pre_include because without it, you can't call hooks within another file. (I'm considering adding the ability to specify an include file in the hook string... What do you think? It might lead to more include_once than necessary, though.)

Okay, I think I'm ready to commit... Too bad I don't have any hooks under the hand to test it, ahah!
Posted: November 12th, 2010, 04:57 PM

Also of note: $modSettings['integrate_magic_quotes'] is never used.
10055
Features / Re: Scheduled tasks interface
« on November 12th, 2010, 03:19 PM »
Yeah but we need an official terminology, so that'll be add-ons I guess ;)
10056
Plugins / Re: Plugin hooks
« on November 12th, 2010, 03:08 PM »
Hmm, I'm nearly done and it's overall okay because most of the calls don't really need to pass a reference. And many of them don't even pass any variables.

I'm just a bit bothered with my cleanup. Instead of having $modSettings['integrate_this_shit'], I now have $modSettings['hooks']['this_shit']. But I was pretty sure $modSettings entries could be arrays, and were serialized and unserialized at load/write time. Apparently, this isn't the case. I can fix that in updateSettings by adding a single is_array() followed by serialize, but is it useful or not? I think it's useful, because modders might find it useful to store arrays into $modSettings at load time, but... Well, I'm just not sure about that particular change.
10057
Plugins / Re: Plugin hooks
« on November 12th, 2010, 02:41 PM »
Quote from Arantor on November 12th, 2010, 02:26 PM
To a point you're getting into the game of second-guessing the developer intent, and without any secondary information, it's hard to be sure.
I have a neat feeling that it can be considered a bug...
But really, it's hard to draw a line between power and security.
For instance, right now I'm in error_handler... Basically, adding a hook to output_error allows a plugin to get data on what error will be shown. However, it can't change anything in that -- whether it be the message or error level. It's pretty much useless, apart maybe for adding a message that says "The error below is normal, don't worry about it."
But if I give plugins the ability to change the error message, they can actually cancel the error itself. Can't they? For instance if I pass a reference to $file, and the plugin replaces it with 'Unknown', voilà, the function just returns without calling anything...
'Oh my'.
Quote
Remember, the integration functions were originally for linking SMF to a third party app, so reset_pass makes sense there, because what you're doing is when a user changes their password in SMF, you're flagging a routine in A.N.Other system to update the same user's password there too.

I'd argue in that case, there shouldn't be a need for the value to be byref. Other instances, however, yes it should be a byref, particularly if it seems logical for a third party app to want to modify something before SMF has its wicked way with it.
So... Where would you put the references, eh? :^^;:
Quote
We're sort of taking that idea and expanding on it, meaning that any original purpose is likely now somewhat irrelevant. For each hook, look at where it is, what local variables are applicable and make a judgement call as to whether it is reasonable and appropriate for third party code (of any kind) to be modifying that. reset_pass is one case it shouldn't be necessary, for example.
I'll let you think about it, too.
There are less than 70 hook calls all in all, so it shouldn't take too long. I'll just rename the hooks for now and I'll let you look into the params call by call if you have time.
10058
Plugins / Re: Plugin hooks
« on November 12th, 2010, 02:16 PM »
Quote from Arantor on November 12th, 2010, 11:02 AM
$context['member'] actually makes sense for the most part since its main use is in the profile area when you're looking at another user's profile,
Yeah, didn't complain about 'member' but about 'user' instead ;)
Quote
Quote
Yeah, adding hooks in the main callee is perfectly fine and I would recommend it, too. Just don't add hooks in every Subs.php function, that's all
That's not anticipation, that would just be stupid :P
I'm working on hooks right now...
- Changing call_integration_hook to call_hook and same for add_hook and remove_hook
- Changing all of the "integrate_*" strings to just "*". This saves space and the modder shouldn't have to care about colliding into a $modSettings variable or something. I haven't decided whether I'll automatically add integrate_ to the name, or do a 'hooks' array, serialized or something, that will be more logically integrated (ahah) into $modSettings.
- Looking into reference passing. It's a bit confusing... Basically, in PHP5, passing references at call time is deprecated, but since an array of references (of varying length) is passed, there's no other way (and that, is not deprecated, obviously.)
However, sometimes SMF passes vars by reference, sometimes not. It's not always obvious WHY. One would think, security? For instance, integrate_reset_pass doesn't pass by reference... Except for ONE function, resetPassword precisely, which does. Now that makes it complicated, doesn't it..? I don't know why exactly one would want to add a hook to resetPassword, but let's say they do. Then should they expect to be able to modify the original variables? If yes, what for? If not, then why do we pass vars by variable in one function?
Anyway, I'll be committing when I'm done. I'll try to document all of my changes to reference passing.
Quote
A lot of the really little tweaks currently published as mods would be tricky to implement directly because of what they do - rearranging little bits of templates, and realistically, those are not possible to hook simply because of the mess you get into because you'd be adding hooks for every single minor point.
I was thinking... Maybe, maybe, we could allow them to rearrange these little bits of templates at runtime, for instance in ob_sessrewrite...? It'd probably be overkill, though. But do you see what I mean? Doing what SMF would usually do at mod applying time, but this time in real time. "Look for <div id='something'>, and add <hello> before it."
Yeah... Overkill, I know ;) But it's something that could avoid having to uninstall & reinstall when upgrading.
10059
Features / Re: Scheduled tasks interface
« on November 12th, 2010, 11:53 AM »
I don't see myself adding the hyphen manually every time... Houston we have a problem. :P

Is it grammatically wrong to say 'addon'?
10060
Plugins / Re: Plugin hooks
« on November 12th, 2010, 10:56 AM »
Quote from Arantor on November 12th, 2010, 10:45 AM
I did that, actually, in a shoutbox I built; as part of the plugin system SimpleDesk had, I did actually add the same hook that the action handler routine has (though calling SD's hook rather than SMF having it), and abused the hook to not only add my action but also to receive the AJAX calls and handle them, as well as manipulating $context at the same time.
I don't understand a word of it, but for instance we could modify said hook to do what SD needs. :P
(You want SD to be ported to Wedge, don't you...? :^^;:)
Quote
Well, they were designed for integration which is where the name comes in, but sure, we can rename them to be more appropriate.
Integration is its purpose, but it shouldn't be its definition. Its definition is a hook.
Imagine that instead of calling parse_bbc(), you had to call parse_bbc_into_an_html_string()
:lol:
Quote
Quote
Yeah, beginning with $context['user']...
I still have no idea why that exists when $user_info contains virtually everything you'd want to know anyway.
Me neither. Probably another example of two vars that developed at pretty much the same time and were favored by one dev or another... Or they wanted to have the "me" equivalent to you's "$context['member']" or something.
Quote
I wasn't going to do it that way, I had a simpler plan - once the action handler was known and the index knew where it was sending the user, I planned to add a hook before and after it has run (since some functions don't return back, and some users will no doubt want to expand upon what's already been done). Yes, there is of course a performance hit there, but the increased flexibility more than makes up for it.
Yeah, adding hooks in the main callee is perfectly fine and I would recommend it, too. Just don't add hooks in every Subs.php function, that's all ;)
Quote
Quote
I think a good policy would be to add a warning when installing a package. In red.
* Arantor likes that idea.
I'm sure most modders will work into making sure their modifications are all turned into hooks at that point.
(It's that's possible, of course. But right now I can't think of anything that isn't.)
10061
Off-topic / Re: PHP 5.3
« on November 12th, 2010, 10:36 AM »
I'm just saying that because a few days I was writing a non-loop code block where I thought, "fuck, if I could add a goto here, that would make my life easier..." (Of course, it didn't take more than a minute to find a workaround.)
10062
Features / Re: Scheduled tasks interface
« on November 12th, 2010, 10:35 AM »
Wiv ze hyphen?
10063
Plugins / Re: Plugin hooks
« on November 12th, 2010, 10:31 AM »
Quote from Arantor on November 11th, 2010, 11:31 PM
It's an interesting idea but not entirely practical,
Yeah, probably isn't, but I just wanted to discuss that.
Quote
mostly because there's already $context, and partly because hooks are there for a specific purpose, not just a convenient place in time; the actions hook for example is there specifically to be used with modifying the list of actions.
But, see, what if the modder wants to do something in that place, but unrelated to the list of actions?

...

...Granted, it's VERY unlikely they would want to. They'll probably even struggle to use the correct hook in itself, uh.
I think modders can start using hooks, as long as we provide them with a dummy mod that would show the correct ways of doing things. (Or some prominent mods start using hooks and they look into their code.)

And as I said earlier, we really should rename the hook functions, too. Right now, it's a bit too long. Do you remember the exact function to call? Yes you do, but how about everyone else?
add_hook('hook_name', 'my_function') would be better, for instance. Or wedge_add_hook().
Even just adding an alias or something...
Quote
Really, pushing things to a 'global local' function is bad juju because really one thing I want to do is empty some stuff out of $context rather than fill it up more.
Yeah, beginning with $context['user']...
Quote
Faster, yes, more likely to collide with new local (temporary) variables but no real issue either way.
This is the kind of change that would be added to the list for modders and themers to look into, so it wouldn't be a problem, they'd just need to do a mass rename and make sure they're not already using $cx somewhere...
Just an idea though, not something I believe in religiously.
Quote
Sure :) Though a fair amount will be anticipation as well,
I'm not much of a fan of anticipation, not because it's extra work for us, but more likely because if we start adding hooks in useless places, like at the beginning of every single function, it will waste CPU time for everyone, possibly for nothing.
Quote
I have a litany of mods in mind that I'm constantly thinking... "how can I make that work without editing the code?" That's really my baseline when I'm thinking of the changes to make.
And that's commendable!
Quote
I'm actually fine with it here, because
...it shows people how we come up with dozens of new ideas every minute, fail miserably at most of them and think of new ideas to build on the failed ones :P
Quote
I want to not only explain why things won't work but also the rationale behind the level of changes we're doing and the real benefits of hooks - while I'm actively going to be encouraging hooks, I want people to understand not only the 'how' but the 'why' as well. Remember, those modders who migrate from SMF are going to initially want to reuse what they've done before,
Maybe for the most important mods, if there are any, we could offer the modder to convert their mods for them. (Uh, well, what do you know, I did exactly that to get SMF2 versions of most of the mods I'm using on Noisen :P)
Quote
and while I'm not planning on pruning the package manager that far, I really don't want to encourage them to continue bad habits.
I think a good policy would be to add a warning when installing a package. In red. "This addon makes modifications to the Wedge files. Please note that if you ever upgrade Wedge, the add-on will stop working. Also, it may get into conflicts with other modification-type addons. Please consider using a plugin-type addon if this doesn't suit you."
Quote
I want them to learn new ones, better ones, ones that will help them grow as developers, knowing as I do that most mod writers are not professional grade programmers.
We've all been noobs before, yes :)
Quote from Arantor on November 12th, 2010, 10:20 AM
$modSettings is for modifiable settings, it contains the contents of the admin panel's options that are forum wide (as opposed to $settings which is theme wide and $options which is user-centric) that are modifiable through the admin panel without editing any files, and is the general home of modification settings too.
Yes, but it's not very instinctive, see?
'mod', to me, really means 'modification', not 'modifiable'... Another fail of SMF's terminology system.
10064
Plugins / Re: Plugin hooks
« on November 12th, 2010, 10:16 AM »
Quote from Arantor on November 12th, 2010, 08:58 AM
SMC = Simple Machines Core, for things that wouldn't necessarily be strictly forum based but usable in other SM apps; it was in the mists of time actually $smfFunc.
Back in Beta 2, I think.
Quote
There are other things we can do at this point, more on that elsewhere.
First of all we should really consider renaming global variables...
Shortening them is a solution. $wf, $cx, $opt, $set, $mset or something.

BTW I never understood why $modSettings is named as such... I mean, it's certainly not reserved to mods! It's a bit disturbing, even for a veteran like me.
10065
Features / Re: Scheduled tasks interface
« on November 12th, 2010, 10:13 AM »
Innit? :P

We'll have to remember this then.

What's going to be the main term? Extensions? Add-ons, or addons?