Attempt to assign property "Allowed" on null"

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
appsols
User
Posts: 46

Attempt to assign property "Allowed" on null"

Post by appsols »

Hello everyone,
I have upgrarded my project developed in 2022 version to latest version 2024. I have successfully generated the files in new version. However, it gives the following error:
C:\wamp64\www\typingchecker\src\userfn.php(79): Attempt to assign property "Allowed" on null.

I'm using PHP version 8.2. I have tried to check the error on the mentioned line. It is given below:

function MenuItem_Adding(&$Item) {
$UserLevel = CurrentUserLevel();
	if($UserLevel==-1)		// Admin; Hide Students Menu
	{
		$ItemID = $Item->Id;
		switch($ItemID)
			{
				case 26:
				case 25:
				case 23:
//Line 79 where error is displayed				$item->Allowed = FALSE;
				break;
			}
	}
	$item->Allowed = TRUE;
}

Can someone help me troubleshoot this. Thank you


mobhar
User
Posts: 11736

Post by mobhar »

For v2024, this code:

function MenuItem_Adding(&$Item) {

should be:

function MenuItem_Adding($item)
{

This code:

$ItemID = $Item->Id;

should be:

$ItemID = $item->Id;

arbei
User
Posts: 9389

Post by arbei »

You may read Migrating to v2024 -> MenuItem_Adding and Menu_Rendering Server Event.


appsols
User
Posts: 46

Post by appsols »

Thank you very much. It solved my problem


Post Reply