RESOLVED: adding a menu item in Joomla 3.0.2 fatal error

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
TheCellarRoom
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Wed Jan 02, 2013 10:09 am

RESOLVED: adding a menu item in Joomla 3.0.2 fatal error

Post by TheCellarRoom » Wed Jan 02, 2013 12:28 pm

After trying to add a menu item to a menu in the backend of Joomla 3.0 that failed due to a duplicate alias accessing the menu section of the backend no longer works. Menu items disappear from the frontend. Trying to add further menu items results in a fatal error

Code: Select all

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 36324 bytes) in \libraries\joomla\table\nested.php on line 1251
deleting the erroneous menu item in the database returns the frontend menu items, but the backend is still not working.

this is the method highlighted in the above error: with ** highlighting the row

Code: Select all

/**
 * Method to recursively rebuild the whole nested set tree.
 *
 * @param   integer  $parentId  The root of the tree to rebuild.
 * @param   integer  $leftId    The left id to start with in building the tree.
 * @param   integer  $level     The level to assign to the current nodes.
 * @param   string   $path      The path to the current nodes.
 *
 * @return  integer  1 + value of root rgt on success, false on failure
 *
 * @link    http://docs.joomla.org/JTableNested/rebuild
 * @since   11.1
 * @throws  RuntimeException on database error.
 */
public function rebuild($parentId = null, $leftId = 0, $level = 0, $path = '')
{
    // If no parent is provided, try to find it.
    if ($parentId === null)
    {
        // Get the root item.
        $parentId = $this->getRootId();
        if ($parentId === false)
        {
            return false;
        }
    }

    // Build the structure of the recursive query.
    if (!isset($this->_cache['rebuild.sql']))
    {
        $query = $this->_db->getQuery(true);
        $query->select($this->_tbl_key . ', alias')
            ->from($this->_tbl)
            ->where('parent_id = %d');

        // If the table has an ordering field, use that for ordering.
        if (property_exists($this, 'ordering'))
        {
            $query->order('parent_id, ordering, lft');
        }
        else
        {
            $query->order('parent_id, lft');
        }
        $this->_cache['rebuild.sql'] = (string) $query;
    }

    // Make a shortcut to database object.

    // Assemble the query to find all children of this node.
    $this->_db->setQuery(sprintf($this->_cache['rebuild.sql'], (int) $parentId));

    $children = $this->_db->loadObjectList();

    // The right value of this node is the left value + 1
    $rightId = $leftId + 1;

    // Execute this function recursively over all children
    foreach ($children as $node)
    {
        /*
         * $rightId is the current right value, which is incremented on recursion return.
         * Increment the level for the children.
         * Add this item's alias to the path (but avoid a leading /)
         */
   ****
        $rightId = $this->rebuild($node->{$this->_tbl_key}, $rightId, $level + 1, $path . (empty($path) ? '' : '/') . $node->alias);
   ****

        // If there is an update failure, return false to break out of the recursion.
        if ($rightId === false)
        {
            return false;
        }
    }

    // We've got the left value, and now that we've processed
    // the children of this node we also know the right value.
    $query = $this->_db->getQuery(true);
    $query->update($this->_tbl)
        ->set('lft = ' . (int) $leftId)
        ->set('rgt = ' . (int) $rightId)
        ->set('level = ' . (int) $level)
        ->set('path = ' . $this->_db->quote($path))
        ->where($this->_tbl_key . ' = ' . (int) $parentId);
    $this->_db->setQuery($query)->execute();

    // Return the right value of this node + 1.
    return $rightId + 1;
}
does anyone have a fix?

the docs article linked in the method details is effectively non-existent.

Notes:

This is on IIS on localhost for dev purposes
set memory limit to 256m and 512m but no change.
changed several other time/size limit settings in PHP.ini but still no joy
restarted server.
no cookies
rebuilt menus and modules - fixes front end display - backend still broken.

Current php ini settings:

Code: Select all

max_execution_time: 3000 3000
max_file_uploads: 200 200
max_input_nesting_level 64 64
max_input_time 600 600
max_input_vars 1000 1000
memory_limit -1 512M
db row content in the #_menu table:

Code: Select all

  '0', 'menutype', 'title', 'alias', '', '', '', 'separator', '1', '1', '1', '0', '0', '0000-00-00 00:00:00', '0', '1', '', '0', '{\"menu_image\":\"\",\"menu_text\":1}', '223', '224', '0', '*', '0'

If for example alias is 'abc123' every other record in the #_menu table has its path field updated to abc123/existing-alias, whilst path remains empty on new row added by trying to add menu item with alias abc123, this row has an id of 0.
Last edited by TheCellarRoom on Thu Jan 03, 2013 2:16 pm, edited 1 time in total.

User avatar
ozneilau
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Tue Aug 04, 2009 9:05 am
Location: Tasmania, Australia
Contact:

Re: adding a menu item to a menu in Joomla 3.0.2 fatal error

Post by ozneilau » Thu Jan 03, 2013 10:41 am

If you haven't already, maybe try emptying the trash to make sure there are no duplicate alias items and then use the rebuild option?

Neil.

TheCellarRoom
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Wed Jan 02, 2013 10:09 am

Re: adding a menu item to a menu in Joomla 3.0.2 fatal error

Post by TheCellarRoom » Thu Jan 03, 2013 12:17 pm

already tried that, rebuilding menus only works if i have manually deleted an entry from the database. otherwise that too fatal errors.

cheers

User avatar
ozneilau
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Tue Aug 04, 2009 9:05 am
Location: Tasmania, Australia
Contact:

Re: adding a menu item to a menu in Joomla 3.0.2 fatal error

Post by ozneilau » Thu Jan 03, 2013 1:03 pm

If there aren't too many menu items, could the menu be deleted and then recreated from scratch?

You might need to set the default home menu option in another menu before being able to delete the current main menu.

Neil.

TheCellarRoom
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Wed Jan 02, 2013 10:09 am

Re: adding a menu item to a menu in Joomla 3.0.2 fatal error

Post by TheCellarRoom » Thu Jan 03, 2013 1:55 pm

I have 20 menus, doesn't matter which menu i try and add an item to i still get the same problem, so i'm not sure how deleting one menu will help.

TheCellarRoom
Joomla! Intern
Joomla! Intern
Posts: 77
Joined: Wed Jan 02, 2013 10:09 am

Re: adding a menu item to a menu in Joomla 3.0.2 fatal error

Post by TheCellarRoom » Thu Jan 03, 2013 2:15 pm

so apparently the error is because there was no primary key set on the _menu table. not sure how or why that has happened. that seems to have fixed the issue. thanks your help

User avatar
ozneilau
Joomla! Guru
Joomla! Guru
Posts: 856
Joined: Tue Aug 04, 2009 9:05 am
Location: Tasmania, Australia
Contact:

Re: RESOLVED: adding a menu item in Joomla 3.0.2 fatal error

Post by ozneilau » Thu Jan 03, 2013 4:06 pm

OK, thanks for letting us know.

Sorry, I should have thought of that becasue I went through that back in October:

http://forum.joomla.org/viewtopic.php?f ... 3#p2922710

This is sometimes caused by the SP Upgrade and JUpgrade migration tools.

Neil


Locked

Return to “Administration Joomla! 3.x”