Check if message queue is empty

361 views
Skip to first unread message

Allon Moritz

unread,
Aug 7, 2013, 9:39:15 AM8/7/13
to joomla-de...@googlegroups.com
hello
how can I check if the message queue is empty? Google didn't help much on this topic :-)

Kannan Naidu

unread,
Aug 7, 2013, 10:24:57 AM8/7/13
to joomla-de...@googlegroups.com
I use this .. it displays the error message when the message is not empty

<?php if(count(JFactory::getApplication()->getMessageQueue())):?>
  bla..bla..bla
<?php endif; ?>


On Wed, Aug 7, 2013 at 9:39 PM, Allon Moritz <allon....@gmail.com> wrote:
hello
how can I check if the message queue is empty? Google didn't help much on this topic :-)

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Kannan Naidu
www.kannannaidu.com
twitter.com/kannannaidu
youtube.com/kannannaidu
My Google + [Add me to your circle]
My Facebook

Allon Moritz

unread,
Aug 7, 2013, 10:26:26 AM8/7/13
to joomla-de...@googlegroups.com
But this empties the queue? After that the messages will not be displayed in the messages part of the template anymore...

laoneo

unread,
Aug 20, 2013, 2:21:23 AM8/20/13
to joomla-de...@googlegroups.com
Does somebody have any hint how to detect if the message queue is empty without getting all the messages out of it?

Thanks.


On Wednesday, August 7, 2013 4:26:26 PM UTC+2, laoneo wrote:
But this empties the queue? After that the messages will not be displayed in the messages part of the template anymore...
On Wed, Aug 7, 2013 at 4:24 PM, Kannan Naidu  wrote:
I use this .. it displays the error message when the message is not empty

<?php if(count(JFactory::getApplication()->getMessageQueue())):?>
  bla..bla..bla
<?php endif; ?>
On Wed, Aug 7, 2013 at 9:39 PM, Allon Moritz  wrote:
hello
how can I check if the message queue is empty? Google didn't help much on this topic :-)

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-dev-general@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-dev-general@googlegroups.com.

piotr_cz

unread,
Aug 21, 2013, 6:46:03 AM8/21/13
to joomla-de...@googlegroups.com
What if you would duplicate the JApplication::getMessageQueue method, just without emptying the queue?

$session = JFactory::getSession();
$sessionQueue = $session->get('application.queue');
$isEmpty = !count($sessionQueue));

It's not forward-compatible/ safe against the session key change, but it's probably the only way now.

IMHO better way would be adding new parameter to the method:

/**
 * @param   boolean  $flush  Flushes the queue. Defaults to true for backward compatibility.
 */
getMessageQueue($flush = true)



On Tuesday, August 20, 2013 8:21:23 AM UTC+2, laoneo wrote:
Does somebody have any hint how to detect if the message queue is empty without getting all the messages out of it?

Thanks.

On Wednesday, August 7, 2013 4:26:26 PM UTC+2, laoneo wrote:
But this empties the queue? After that the messages will not be displayed in the messages part of the template anymore...
On Wed, Aug 7, 2013 at 4:24 PM, Kannan Naidu  wrote:
I use this .. it displays the error message when the message is not empty

<?php if(count(JFactory::getApplication()->getMessageQueue())):?>
  bla..bla..bla
<?php endif; ?>
On Wed, Aug 7, 2013 at 9:39 PM, Allon Moritz  wrote:
hello
how can I check if the message queue is empty? Google didn't help much on this topic :-)

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.

Allon Moritz

unread,
Aug 21, 2013, 6:51:11 AM8/21/13
to joomla-de...@googlegroups.com
I think duplicating it is not an option because the messages are cached in an array after the first access. But I like the idea of adding an extra parameter. Do you think a pull request would be accepted?


To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.

piotr_cz

unread,
Aug 21, 2013, 3:31:08 PM8/21/13
to joomla-de...@googlegroups.com
It's really hard to tell, it's been a while since my PR has been merged. But this issue omes back once a time and IMHO optional parameter is way out

Michael Babker

unread,
Aug 21, 2013, 3:41:07 PM8/21/13
to joomla-de...@googlegroups.com
To retrieve the message queue without clearing it, your best option most likely is to basically hack the API via Reflection.  The queue is stored in a protected access internal array within JApplication and only set to the session when requests are made.
 
$reflection = new ReflectionClass(JFactory::getApplication());
$queueProp = $reflection->getProperty('_messageQueue');
$queueProp->setAccessible(true);
$messageQueue = $queueProp->getValue(JFactory::getApplication());


On Wed, Aug 21, 2013 at 2:31 PM, piotr_cz <pkoni...@hotmail.com> wrote:
It's really hard to tell, it's been a while since my PR has been merged. But this issue omes back once a time and IMHO optional parameter is way out
Reply all
Reply to author
Forward
0 new messages