New revs - Public comments

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: New revs - Public comments
« Reply #120, on September 23rd, 2011, 07:41 AM »
The function will be moved to the index template as discusses earlier. ;)

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
The way it's meant to be

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: New revs - Public comments
« Reply #122, on September 23rd, 2011, 12:59 PM »
Quote from Arantor on September 23rd, 2011, 12:57 AM
Quote
The fact that $where defaults to 'replace' when $target == 'default and defaults to 'add' everywhere else...
Seriously, it's fine. It might sound odd but it actually works fairly well in practice (now that WedgeDesk does it)
Uh... I suppose.
But there's much to be said. For instance:

loadBlock('my_block', array('sidebar', 'default'))

Will add my_block to the sidebar. If not found, however, it will be added to (and NOT replacing) the default layer... Looks logical to me. The other way around (array('default', 'sidebar')) doesn't make sense because default is always there.

Okay, done on my local install... (Hopefully will work fine.)

I'd be tempted, though, to split these into more functions, like 'replaceBlock' and 'addBlock'... Dunno which would be best, really (especially given the number of choices I offer. One function for each...?!)
Or perhaps just alias functions. I mean, it's not like they're called a lot anyway...

function replaceBlock($block, $target)
{
   loadBlock($block, $target, 'replace');
}

Also transformed the info center into the layer. 'info_center_begin' and 'info_center_end' bothered me too much... :lol:
Quote
Whether it being worth the hassle is a good question. But it would certainly prevent random tampering with the arrays directly, and it becomes more semantic because instead of having generic (but nicely named) functions, you have an object to which all the functions physically belong.
Yes, I suppose it's a nice way of doing it.
But loadBlock() is short and sweet. I don't know if wetem::loadBlock() would be better. Or wetem::load_block. Or wetem::load() with Wedge guessing by itself what the contents is (heck, I could do it... I'm just not sure it's as readable!)
Or having functions outside the object, and the object only manipulated through these functions like loadBlock()...?
Quote
This is one of the issues I have with SMF's error messages. In the event of a database error, it can quite easily say something to the effect of "There has been a database error, please refer to the administrator." Which is fine - until it displays that message, as is, to an administrator when they're logged (and after determination of permissions has occurred)
Yeah, true dat!
It would make sense to actually display the faulty query etc to them...
Quote
Quote
No, that's not what I was saying... If a board has a default language, different than the forum's, *and* the admin disabled the ability to change languages for users, i.e. $modSettings['userLanguages'] or whatever is false, then getLanguages() is not called... And my test code isn't, either.
Hmm, not sure how to proceed on that one.
I believe we should store somewhere the number of language files available. If it's > 1 we call getLanguages() either way. We'll only use $modSettings['userLanguage'] when in the index template, just before showing the flags themselves.
Quote
Also, in add-on related news, WedgeDesk is now capable of being installed (and running) cleanly from the add-on manager. The only thing it can't handle right now is attachments, and that's only because it's expecting to use the old attachment handling code which I haven't removed yet.
Ah, attachments and avatars...

It's probably my greatest failure of these last few months. Have you noticed how I keep postponing them...?
It's mainly because I'm afraid doing these changes will push me into a 3-month bug hunt that will prevent us from showing Wedge to the public, etc. I keep thinking of situations where the current attachment and avatar systems make more sense than Aeva's, *or* may require users to change the way they see things. I'm already considering ensuring the avatar and attachment albums won't be browsable by users (bit wary of the permission issues -- way too risky). Things like that, from which I'm backing off... (backing away?)

To be honest -- apart from the cool fact that Aeva would allow user to rotate through their favorite avatars (I do have a local folder of my favorite avatars but maintaining it is a hassle), the main reason why I released Aeva Media 2.10 (you know, the failed one :P) *AND* wanted to have v2.10 in Wedge (instead of 1.x), *AND* wanted to replace the avatar system with Aeva, is because.... Wait for it... I love having a drop shadow on my avatar, and want it on every forum I go to, but I just don't want a drop shadow when I'm using a transparent avatar!

Yeah... That's, basically, the only reason I did all of it.

I'm stupid.
Quote
On that note, actually... I was thinking about how to handle attachment access for things like WedgeDesk that have their own authentication needs and that have different needs to the norm. Galleries, by definition, are accessed at gallery level, but we need to change that to being determined at board level for attachment gallery items.
Yeah, and more than that... Topic level. See what I mean. (If we implement topic privacy. Another of my recent failures.)
Quote
I'm not sure how we'd do *that*, but the solution for handling attachments generally when it's an external source seems fairly clear: have a hook that attempts to make the query that Dlattach.php normally would (or MGalleryItem.php, whatever query would normally be run to identify a file and validate the user can access it), and the hooked functions should return the necessary information, or false - that way, systems can deal with it as necessary.
I'm not sure I understand.

Oh, and if we have board-level permissions, then I suppose we could (should?!) modify Aeva to use boards and topics instead of albums and items. Not sure about that yet, though... It basically means implementing the floating topic stuff.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #123, on September 23rd, 2011, 01:37 PM »
I'm cool with the template changes :)
Quote
I'd be tempted, though, to split these into more functions, like 'replaceBlock' and 'addBlock'... Dunno which would be best, really (especially given the number of choices I offer. One function for each...?!)
I'd avoid making too many functions, especially if they're fairly similar or related. Trust your instincts on this one.
Quote
Or having functions outside the object, and the object only manipulated through these functions like loadBlock()...?
No, if you have an object whose job it is to handle the template skeleton, not only is it the holder of the data, but it's also responsible for changing that data. In any case, if it's to be tamper-proof except for through the defined methods, the methods have to be part of the object because you'd make the list itself a private variable - which by definition can only be manipulated inside the object's own methods, and is never made directly available outside of it.
Quote
Yeah, true dat!
It would make sense to actually display the faulty query etc to them...
At least then there would be a useful start to debugging...
Quote
I believe we should store somewhere the number of language files available. If it's > 1 we call getLanguages() either way. We'll only use $modSettings['userLanguage'] when in the index template, just before showing the flags themselves.
You know, we could just ship with both English and French installed by default so it's always > 1 :whistle:
Quote
It's probably my greatest failure of these last few months. Have you noticed how I keep postponing them...?
I had noticed, but I'm not in the slightest surprised. It's a massive undertaking at the best of times, and it has so many knock-on effects that it will inspire fear and dread in anyone.
Quote
I keep thinking of situations where the current attachment and avatar systems make more sense than Aeva's
There aren't that many situations, and frankly I think they're avoidable too.

The main ones that I envisage are where you end up with what amounts to a single album that contains all the attachments, but that access rights to that album are inconsistent with how an album usually functions. That, and separating viewing a thumbnail from viewing the main file (it's a fairly common request because SMF says either you can see it or you can't, no in-between ground)
Quote
*or* may require users to change the way they see things
As you reminded me yesterday, http://yarr.me/cache/8a07b66f80a1982895b8acf157fe1002.jpg

I have no problem with changing how users see things, provided that where we go to is a logical, meaningful place. To me, sifting out the code so that we have one path for accessing attachments/avatars/gallery items seems like a logical place to go - and we get the benefits of integrating Zoomedia cleanly :)
Quote
I love having a drop shadow on my avatar, and want it on every forum I go to, but I just don't want a drop shadow when I'm using a transparent avatar!
Nothing wrong with having ambition. Maybe that is a little unbalanced in terms of work vs reward (though far less so than building a wall just to put a hook on it for a coat), but I think it's a meaningful one because right now we have two distinct paths to serving files and so on, even though the operations are virtually identical, and we should fix that.

Really: what's the difference between what MGalleryItem does and what Dlattach does? They still look up where a file is, whether the user can see it or not, and ultimately serve the file.
Quote
Yeah, and more than that... Topic level. See what I mean. (If we implement topic privacy. Another of my recent failures.)
Again, I don't really see it as a failure, no more so than my not having reimplemented permissions yet. It's just another thing to do that has massive system-wide consequences and can easily turn into a tour-de-force of bug hunting.
Quote
I'm not sure I understand.
OK, best thing to do is take a look at the code in the modified Download() function in Display.php on this site (or, failing that, a fresh 2.0 final install with SD 2.0 installed).

Firstly, it checks for 'avatar' in the URL, and if so, it queries for the avatar's details (filename etc.). If not, SD's injected code looks for 'ticket' in the URL, and if so, it tries to query for the details *there*. Failing that, it just looks for the normal route (attach id + topic id)

Note that it doesn't *fetch* the information at this point, merely queries for it, and then passes the query result to the fetch code, so regardless of the query actually run, it knows that no rows means the attachment can't be found or seen (either way, it neither knows nor cares which), otherwise it serves the file it has.

SD added its own handler in there, and I can envisage something similar in the attachment code, whatever form it's in, to have a hook, and see if anything attached to the hook will validate the requested file, and if so, prepare to serve it.
Quote
Oh, and if we have board-level permissions, then I suppose we could (should?!) modify Aeva to use boards and topics instead of albums and items. Not sure about that yet, though... It basically means implementing the floating topic stuff.
Yup. So many inter-related parts, it's so hard to judge where to start.
Re: New revs - Public comments
« Reply #124, on September 23rd, 2011, 08:28 PM »
Btw, when I first split the info centre up way way back, there weren't arbitrarily nested layers the way that the skeleton now exists - we only had the single array of templates, good that it's been tidied up :)
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082

live627

  • 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,670
Re: New revs - Public comments
« Reply #126, on September 24th, 2011, 01:40 AM »
loadAddonLanguage: If the file isn't found, an undefined variable error occurs ($found)
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #127, on September 24th, 2011, 01:49 AM »
Eeek, I'd better fix that! Thanks for the heads-up!

(I'll fix it in my local copy which has a bunch of related stuff in it and commit it all together.)

live627

  • 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,670
Re: New revs - Public comments
« Reply #128, on September 24th, 2011, 02:10 AM »
Sure, and while I'm at it, before I run, I have four ENUM columns for my addon. None specify a default, in fact, no /columns have a default. Yet, the query forces a blank default, which throws an error on ENUM. This tripped me up for a while, until I figured out what was going on.

Is there a specific reason for forcing a default? I could circumvent the problem by removing it, which seems to be accepted in MySQL.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #129, on September 24th, 2011, 02:14 AM »
Hmm. I don't recall forcing a default in ENUM columns but to be fair I never *actually* tested ENUM columns, so I expected it to be a bit broken.

If no default is specified, one shouldn't be used - however, using defaults is a good practice because it means you don't have to worry about it on insertion if you don't have to change it. (And some columns, like text/mediumtext, must not have a default)

Guess that needs to be fixed, but I wouldn't describe it as battle-hardened. It works for what I've thrown at it thus far... but that's not extensive or exhaustive.

Nao

  • Dadman with a boy
  • Posts: 16,082

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: New revs - Public comments
« Reply #131, on September 24th, 2011, 02:27 AM »
AeMe 2.10 was specifically the reason why I added ENUM support :P But it wasn't tested thoroughly, it just means that the code which deals with defaults is a shade buggy, not that it's a hellhole of support nightmare :P
Re: New revs - Public comments
« Reply #132, on September 24th, 2011, 02:58 PM »
I've committed the undefined found variable fix, haven't looked into ENUM yet, but will do in a bit.
Posted: September 24th, 2011, 02:14 PM

And I think I nailed the ENUM issue as well :)

live627

  • 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,670

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278