avines002

About me: Student at University of Texas at Arlington
Location:
Website: http://
Email:

Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Group membership

Activity

  • avines002 has updated their profile
  • avines002 replied on the discussion topic getTimeUpdated returning unexpected results
    this returns the old updated time:$object->getTimeUpdated(); this returns what i want:get_entity($object->getGUID())->getTimeUpdated();   this is what I think is happening:I read $object, change something, then getTimeUpdated() is... view reply
  • avines002 replied on the discussion topic getTimeUpdated returning unexpected results
    this gives me two different values, why?? $object->getTimeUpdated();get_entity($object->getGUID())->getTimeUpdated(); view reply
  • avines002 added a new discussion topic getTimeUpdated returning unexpected results in the group Plugin Development
    hello everyone, I have been developing a plugin, users can update an object, then the function returns the last time updated to be stored at the user side--the user can then tell if this object has been changed since they did last. So, why is it,...
    • The first thing that the $entity->save() does for an existing entity is that it uses cache_entity() to save the entity also to the global $ENTITY_CACHE. The time_updated is however added to the data in the update_entity() function that the save calls. So this is why the time_updated does not get to the cache.

      I wonder if there's some particular reason why the time_created cannot be added to the entity already before calling the cache_entity() and save() functions. That way the new time_updated could be found also from the cache and not only from the database.

    • yes - time_updated is stored to the db at time an entity is ->saved via ->save() => update_entity() and not before -- cache is only refreshed at that time. and so -- to make time_updated refresh in cache would mean some hacked 'direct' update of either the db or hooking into the core's save() function ;-(

  • avines002 joined the group General Discussion
  • avines002 replied on the discussion topic locking the database?
    i tried something similar to that. I have a lock object, when person A reads, it locks it, modifies the object, then unlocks it. This doesn't work either. There seems to be a race condition: person A readsbefore person A locks it, Person B... view reply
  • avines002 added a new discussion topic locking the database? in the group Plugin Development
    hello everyone, I am creating a plugin where users associated with a group will be able to modify a certain elgg object. But i am getting synchronization issues. A member of a group can modify the object, but we don't want another person of the...
    • You can create a field in the object caled version... when the object save you add 1 to version... if other a user try save the object with a smaller version you dont save and show a message....

       

    • i tried something similar to that. I have a lock object, when person A reads, it locks it, modifies the object, then unlocks it. This doesn't work either. There seems to be a race condition:


      person A reads
      before person A locks it, Person B reads
      Person A modifies then unlocks
      Person B locks it, modifies, unlocks

      problem is when person B read, it didn't know person A had already read it and is in the process of modifying it.

      some of the psuedocode is here:

      user=get_logged_in_user_id()
      group=elgg_get_entities(type=group)

      foreach group as groups
           g=users Group

      object=elgg_get_entities()

      foreach object as object
           find object with relationship to group
           check lock
               if locked return
               if unlocked, lock
           modify
           save
           unlock

      return

       

      Like is said, seems to be that person A locks it, person B starts reading, person A modifies ( and now person B has old version read), person A unlocks, person B locks, modifies, unlocks.

      This is the same case if i do create another field. Before Person A can update version, person B has already read it.

    • Look up PHP's semaphore implementation - your answer lies in there.

  • avines002 replied on the discussion topic metadata as arrays
    I just abandoned the idea of arrays. I ended up with much more coding than had anticipated, but it works nontheless. view reply