Page 1 of 1

Trying to get property of non-object - if active menu null

Posted: Fri Jan 09, 2015 5:06 pm
by tkuschel
Hi,
if a menu structure was changed or article is available through the joola compontent (without a menu) a message is thrown:
[Fri Jan 09 14:42:01 2015] [error] [client 68.180.228.169] PHP Notice: Trying to get property of non-object in /var/www/cms/plugins/content/admirorgallery/admirorgallery/classes/agGallery.php on line 353
[Fri Jan 09 15:03:29 2015] [error] [client 212.186.180.210] PHP Notice: Trying to get property of non-object in /var/www/cms/plugins/content/admirorgallery/admirorgallery/classes/agGallery.php on line 353

At line 353, I changed it to:

Code: Select all

// Breadcrump Support
			$active = JFactory::getApplication()->getMenu()->getActive();
			if (isset($active) && $active->query['view'] == 'layout')  $this->writeBreadcrum();

so only when menu item is not null and exists, the writeBreadcrum() is called;

Thomas

patch:

Code: Select all

--- agGallery_orig.php	2015-01-09 15:04:25.000000000 +0100
+++ agGallery.php	2015-01-09 15:31:50.000000000 +0100
@@ -1,5 +1,6 @@
 <?php
  /*------------------------------------------------------------------------
+ LOYTEC patch 2015-01-09
 # admirorgallery - Admiror Gallery Plugin
 # ------------------------------------------------------------------------
 # author   Igor Kekeljevic & Nikola Vasiljevski
@@ -348,12 +349,14 @@
                         ';
                 }
             }
-
-            // Breadcrump Support           
-            if (JFactory::getApplication()->getMenu()->getActive()->query['view'] == "layout") {
-                $this->writeBreadcrum();
-            }
-
+			//tk LOYTEC patch 2015-01-09
+			// Breadcrump Support
+			$active = JFactory::getApplication()->getMenu()->getActive();
+			if (isset($active) && $active->query['view'] == 'layout') $this->writeBreadcrum();
+			/*if (JFactory::getApplication()->getMenu()->getActive()->query['view'] == "layout") {
+				$this->writeBreadcrum();
+			}
+			*/ //tk--
             $this->doc->addScriptDeclaration('var albumInitFolders_' . $this->articleID . '="' . implode(",", $this->albumInitFolders) . '";');
         }
         $this->imagesFolderPhysicalPath = $this->sitePhysicalPath . $this->params['rootFolder'] . $this->imagesFolderName . DS;


Re: Trying to get property of non-object - if active menu nu

Posted: Thu Mar 19, 2015 3:26 pm
by Vasiljevski
Thanks for reporting this. I added it to our Git repository in revision 4 :)