akeeba / fof

Rapid Application Development framework for Joomla!™ 3 and 4
0 stars 0 forks source link

FOF 2.x behaviors are not working in PHP 7 #593

Closed rameshelamathi closed 8 years ago

rameshelamathi commented 8 years ago

Hi

If we have one or more default behaviors (like filters, access), then FOF takes only the first behavior and ignores the rest. Here are the results of tracing the issue so far:

While attaching, F0FUtilsObservableDispatcher -> attach method maintains the current position of the observers array at 0. Line number 228 at fof/observable/dispatcher.php $key = key($this->_observers);

The $key is always 0.

I am stuck at this point now. :-(

nikosdion commented 8 years ago

Unfortunately FOF 2 is deprecated and on its way to being completely discontinued. For over a year we've been telling developers to upgrade to FOF 3. We are not going to address any further issues in FOF 2. My recommendation is to upgrade your components to FOF 3.

Nicholas K. Dionysopoulos Director, Akeeba Ltd https://www.AkeebaBackup.com https://www.akeebabackup.com/

Στις 25 Μαρ 2016, 08:39 , ο/η rameshelamathi notifications@github.com έγραψε:

Hi

If we have one or more default behaviors (like filters, access), then FOF takes only the first behavior and ignores the rest. Here are the results of tracing the issue so far:

While attaching, F0FUtilsObservableDispatcher -> attach method maintains the current position of the observers array at 0. Line number 228 at fof/observable/dispatcher.php $key = key($this->_observers);

The $key is always 0.

I am stuck at this point now. :-(

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/akeeba/fof/issues/593

rameshelamathi commented 8 years ago

Thank you Nicholas. We have already upgraded the components to FOF 3 and testing them right now. Will be releasing with FOF 3 by the end of this month.

Some of our users are using the old version with FOF 2 and they reported the issue. Since they customised their shops (unfortunately by editing core files against our recommendation), they could not update. We kind of a caught in the middle. Could not turn down their request :-( So trying to see if we can sort it out.

It works good if we use just one behaviour (which is how the core component works and it works good in PHP 7). Some of the plugins add more than one behaviour to add additional functionality (like pricing calculators). That is when the issue starts.

Let me trace further and try to solve it.

Thanks again for the quick response. Best in class and a great inspiration :-) Ramesh

nikosdion commented 8 years ago

You were very, very close. If you read PHP 7's backward incompatible changes notes you'll see that foreach now doesn't change the internal array pointer. In the two foreach loops you traced one uses end($this->_observers), the other doesn't. So if you pass a callback observer the end($this->_observers) code will set the array pointer to the end of the array. The other, lacking this code, would work on PHP 5 because the foreach above it would set the array pointer to the very end whereas under PHP 7 it wouldn't. By adding end($this->_observers) we restore PHP 7 compatibility.

rameshelamathi commented 8 years ago

Thank you so much. You are awesome :-)

nikosdion commented 8 years ago

You're welcome :)