Meeting notes - 2011-09-13

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Crell's picture

We had a very productive, very focused meeting earlier today for the WSCCI initiative. There were about a half-dozen or so active participants, plus a few others who were more quiet. No one was around that wanted to talk about the UX thread, so we spend a little over an hour talking about the handling of empty values returned from context handlers and how that affects traversal of the context hierarchy. (I know, really exciting stuff, right?)

The basic problem was that there are four things that a context handler could return:

  1. A useful value
  2. False (which is a special case of a useful value)
  3. "I don't know what the value of this key is, but you should keep looking".
  4. "There is no value here. Trust me on this."

And we can only use NULL to mean one of those last two, because those are both legitimate use cases.

In the end, we concluded that NULL should mean #3 (I don't have a value, keep looking). For #4, we will introduce a new empty object specifically for the #4 return type. The context object, when traversing, will read an object of that type as "return null now, don't keep looking". NULL will mean "keep looking, unless you run out of keys all the way down the stack, and then return NULL".

We also discussed what offsetExists() should do on the context object. After some back and forth, catch pointed out that we should just follow the lead of the DrupalCacheArray object:

<?php
public function offsetExists($key) {
  return (
$this->offsetGet($key) !== NULL);
}
?>

Sometimes the simple answers are the right ones. :-) That means we only have one set of traversal logic. While it's possible to end up double-traversing, in practice we don't anticipate it being a major issue especially once we sort out caching.

Combined with the "traverse the key first, then the stack" logic we agreed upon in this issue, that should take care of most traversal logic.

Pounard volunteered to adapt the existing patch to handle this new logic, and already has code available for review! Please see this comment and post comments. :-)

Comments

re: offsetExists() -- I'm

sdboyer's picture

re: offsetExists() -- I'm wearing my hopeful face that you've taken into consideration the multidimensional array issues inherent in ArrayAccess implementations in all the work you've been doing? Haven't been following closely, so I just want to raise the flag.

Side-stepped

Crell's picture

We haven't addressed it directly. However, since we're looking at eventually not allowing arrays as context values in the first place, just scalars and objects, we would never run into that issue. Even if we did allow it, the key structure is delimited string, so in practice I don't think we'll run into it that often. offsetExists() for us will specifically be "does this key exist in the context", so I don't know why someone would run a command that would trip that bug.

Thanks for the reminder, though. It's another annoying part of PHP. :-/

damn, we did not

Stalski's picture

I have to say, it's funny to read this now as I found this problem myself last week. I did not know this happened with ArrayAccess as well. (The case I had is in D7 when you use a real object as the entity object. You can thus only do two things: extend on stdClass: bah, or use magic functions. The later does not work as setting a second level property will lead to getting the level1 property in "read" mode, resulting in the same "Indirect modification of overloaded element ")

I'll take this with us in [#1261156], but as you mentioned, this results in the requirement of php5.3.4.
Thx for the feedback, Sam.

Stalski

Sorry I missed the discussions

Itangalo's picture

I would have loved to discuss the UX aspects, but didn't know about the meeting. I obviously need to keep a closer eye on this group.

//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 190+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding. Creative Commons license!

Sorry I did not make it to the meeting

fgm's picture

I was just wondering when the next meeting was when I read this. Too bad! I would have attended otherwise. The #drupal-wscci channel topic always says " Meeting today at noon US ET", whatever the day, making it unusable as a planning source.

When is the next one planned ?