Skip to content

Instantly share code, notes, and snippets.

@yireo
Last active December 19, 2015 00:09
Show Gist options
  • Save yireo/5867006 to your computer and use it in GitHub Desktop.
Save yireo/5867006 to your computer and use it in GitHub Desktop.
After upgrading Joomla! through a tool like SPUpgrade or JUpgrade, the component_id might be set wrongfully within the menu-table. leading to Menu-Items that are indicated with a red cross. This script updates the component_id-field with the new component ID.
<?php
// Define variables
define('DOCUMENT_ROOT', dirname(__FILE__).'/');
define('_JEXEC', 1);
define('JPATH_BASE', DOCUMENT_ROOT);
define('DS', DIRECTORY_SEPARATOR );
if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = null;
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport('joomla.environment.request');
jimport('joomla.database.database');
// Start the application
$app = JFactory::getApplication('site');
$app->initialise();
$db = JFactory::getDbo();
$componentName = 'com_magebridge';
$component = JComponentHelper::getComponent($componentName);
$componentId = $component->id;
if(!$componentId > 0) die('Invalid component');
$query = "UPDATE #__menu SET `component_id`=".$componentId." WHERE `link` LIKE 'index.php?option=".$componentName."%'";
$db->setQuery($query);
$db->query();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment