english/administrator/components/com_menus/controllers/menus.php
/**
	 * Temporary method. This should go into the 1.5 to 1.6 upgrade routines.
	 */
Temporary method. This should go into the 1.5 to 1.6 upgrade routines.
Temporary method . This should go into the 1 . 5 to 1 . 6 upgrade routines .
public function resync()
	{
		$db = JFactory::getDbo();
		$parts = null;
		$components = $db->setQuery(
			'SELECT element, extension_id' .
			' FROM #__extensions' .
			' WHERE type = '.$db->quote('component')
		)->loadAssocList('element', 'extension_id');
		if ($error = $db->getErrorMsg()) {
			return JError::raiseWarning(500, $error);
		}
		$items = $db->setQuery(
			'SELECT id, link, component_id' .
			' FROM #__menu' .
			' WHERE type = '.$db->quote('component')
		)->loadObjectList();
		if ($error = $db->getErrorMsg()) {
			return JError::raiseWarning(500, $error);
		}
		foreach ($items as $item) {
			parse_str(parse_url($item->link, PHP_URL_QUERY), $parts);
			if (isset($parts['option'])) {
				$option = $parts['option'];
				if (isset($components[$option])) {
					$componentId = $components[$option];
				} else {
					$componentId = -1;
				}
				if ($item->component_id != $componentId) {
					$log = "Link $item->id refers to $item->component_id, converting to $componentId ($item->link)";
					echo "<br/>$log";
					$db->setQuery(
						'UPDATE #__menu' .
						' SET component_id = '.$componentId.
						' WHERE id = '.$item->id
					)->query();
					if ($error = $db->getErrorMsg()) {
						return JError::raiseWarning(500, $error);
					}
				}
			}
		}
	}
public function resync ( ) { $ db = JFactory :: getDbo ( ) ; $ parts = null ; $ components = $ db -> setQuery ( 'SELECT element, extension_id' . ' FROM #__extensions' . ' WHERE type = ' . $ db -> quote ( 'component' ) ) -> loadAssocList ( 'element' , 'extension_id' ) ; if ( $ error = $ db -> getErrorMsg ( ) ) { return JError :: raiseWarning ( 500 , $ error ) ; } $ items = $ db -> setQuery ( 'SELECT id, link, component_id' . ' FROM #__menu' . ' WHERE type = ' . $ db -> quote ( 'component' ) ) -> loadObjectList ( ) ; if ( $ error = $ db -> getErrorMsg ( ) ) { return JError :: raiseWarning ( 500 , $ error ) ; } foreach ( $ items as $ item ) { parse_str ( parse_url ( $ item -> link , PHP_URL_QUERY ) , $ parts ) ; if ( isset ( $ parts [ 'option' ] ) ) { $ option = $ parts [ 'option' ] ; if ( isset ( $ components [ $ option ] ) ) { $ componentId = $ components [ $ option ] ; } else { $ componentId = - 1 ; } if ( $ item -> component_id != $ componentId ) { $ log = " Link  $ item -> id  refers to  $ item -> component_id , converting to  $ componentId  ( $ item -> link ) " ; echo " <br/> $ log " ; $ db -> setQuery ( 'UPDATE #__menu' . ' SET component_id = ' . $ componentId . ' WHERE id = ' . $ item -> id ) -> query ( ) ; if ( $ error = $ db -> getErrorMsg ( ) ) { return JError :: raiseWarning ( 500 , $ error ) ; } } } } }
Temporary method.
Temporary method .
// Initialise variables. // Load a lookup table of all the component id's. // Load all the component menu links // Parse the link. // Tease out the option. // Lookup the component ID // Mismatch. Needs human intervention. // Check for mis-matched component id's in the menu link. // Update the menu table. //echo "<br>".$db->getQuery();