[SOLVED] 1.11.7 broken after move - global content goes AWOL

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

[SOLVED] 1.11.7 broken after move - global content goes AWOL

Post by rotezecke »

a second issue that i think i should post separately. same background story:

my host copied a CMSMS 1.11.7 website to a new server.

after i call certain pages, things seem to go crazy, which looks like global content blocks cannot be found. instead I see this in html

Code: Select all

<!-- Html blob 'JS_head' does not exist  -->
i also found this in admin log:
Global Content Block: system calculation warning
Can not open or does not exist!

note the GCB is actually named (and correctly called) system_calculation_warning

I assume there's a UDT that causes all this. if anyone has experienced similar issues i'd like to hear from you. cheers,
Last edited by rotezecke on Thu Sep 12, 2013 6:17 am, edited 1 time in total.
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: 1.11.7 broken after move - global content blocks go AWOL

Post by rotezecke »

I think I dont close database connections properly as debug shows that I'm trying to retrieve the data from the wrong database. I have multiple UDTs that access different databases, and in the past I didnt use mysql_close() as it always worked without. is there a CMSMS way to reconnect to its native database (for UDT)?
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: 1.11.7 broken after move - global content blocks go AWOL

Post by rotezecke »

adodb_connect();

at end of UDTs makes a difference! How did it ever work without?
User avatar
Owens
Forum Members
Forum Members
Posts: 97
Joined: Thu Dec 27, 2007 11:29 pm

Re: 1.11.7 broken after move - global content blocks go AWOL

Post by Owens »

rotezecke wrote:adodb_connect();

at end of UDTs makes a difference! How did it ever work without?
You are correct.

Your UDTs that are using a different database should then use adodb_connect() to re-establish connections to the primary database that is setup for CMSMS.

I only know that because I've run into the same problem before ;p

Sorry it took me so long to respond to your question. Looks like you have it all sorted.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: [SOLVED] 1.11.7 broken after move - global content goes

Post by Rolf »

rotezecke wrote:i also found this in admin log:
Global Content Block: system calculation warning
Can not open or does not exist!
Nice hehh :)
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: 1.11.7 broken after move - global content blocks go AWOL

Post by Rolf »

rotezecke wrote:adodb_connect();

at end of UDTs makes a difference! How did it ever work without?
What is the content of that UDT, Rotezecke?
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: [SOLVED] 1.11.7 broken after move - global content goes

Post by rotezecke »

I'm not sure anymore, I have about 20 UDTs that access another database, 3 or 4 of them were playing up after I moved the site to a new server. adding "adodb_connect();" at the end fixed the problem for all of them. However, some of my UDTs did not require this, but I ended up adding that line to all of them. The only other time I observed this problem is described here http://forum.cmsmadesimple.org/viewtopi ... 48#p307348
but tristan was correct, my subsequent edit only triggered a cache refresh as I couldnt reproduce the problem when I rolled back the code.
here's a UDT that I believe stopped working at the time:

Code: Select all

//create link using (duplicated) SEO_URL logic
//script completely ignores SEO_URL backend settings
//ms 5.11.13
//requires products ID as params['id']
//optional:
//text, assign 
//warning emails go to:
$webmaster = 'webdude@xxxxx';
// ------------------ dont edit below unless you know what you're doing --------------
//get database credentials
require "ms_config/db.php";
//connect - using ADOdb lite syntax
$db = NewADOConnection('mysql');
$db->Connect($db_host,$db_user,$db_pw,$db_db);
//products_id
$product = array((int)$params['id']);
//only active products, dont bother about language settings
$query = "SELECT products_name as pName, products_seo_url as psu FROM products_description pd JOIN products p ON pd.products_id = p.products_id WHERE pd.products_id = ? AND p.products_status = '1'";

$result = $db->GetArray($query,$product);

//send email on error
$error = false;
if (!$result  ) {
    $error=true;
    $msg = 'Check product ID '.$product[0]. ' found on page (alias): '. $smarty->get_template_vars('page_alias');
    mail($webmaster,'Error by osc_product_link UDT',$msg); 
} else {
$row = $result;
//no error
//no URL? use name instead
     if($row[0]['psu'] != '') {
	$pName = $row[0]['psu'];
     } else {
        $pName = $row[0]['pName'];				  
     }
//strip most special characters (not the underscore)
     $pattern = "/([^a-zA-Z0-9_[:space:]])+/";
     $anchor = preg_replace($pattern, '', trim(strtolower($pName)));
//replace with - dashes
     $pattern = "/([[:space:]]|[[:blank:]])+/"; 
     $anchor = preg_replace($pattern, '-', $anchor); 
//strip short words ($limit), unless separated with underscores
     $limit = 3;
     $foo = @explode('-', $anchor);
     foreach($foo as $index => $value){
	switch (true){
		case ( strlen($value) <= $limit ):
			continue;
		default:
			$container[] = $value;
			break;
	}		
     } 
     $container = ( sizeof($container) > 1 ? implode('-', $container) : $anchor );
     $container = str_replace('_','-',$container);
     //get root url
     $config = cmsms()->GetConfig();	
     $seo_url = $config['root_url'] . "/catalog/".$container ."-p-".$product[0] .".html";
     if($params['text'] != '') {
           $seo_url = '<a href="'.$seo_url.'">'.$params['text'].'</a>';
     }
}
//assign results or print to screen
if(isset($params['assign']) && $params['assign'] != '' && !$error) {
     $smarty->assign($params['assign'], $seo_url);
} else if(isset($params['assign']) && $params['assign'] != '' && $error && $params['text'] != '') {
     $smarty->assign($params['assign'], $params['text']);
} else if(isset($params['assign']) && $params['assign'] != '' && $error) {
     $smarty->assign($params['assign'], '#');
} else if(!$error) {
     echo $seo_url;
} else if($error && $params['text'] != '') {
     echo $params['text'];
} else if($error) {
     echo '#';
}

adodb_connect();
the UDT requires a product ID and ideally some text, it connects to another DB and finds associated SEO URL and returns a link to that product, but more importantly, it sends an email when a product goes missing (disabled, deleted), in which case the UDT also returns plain text instead of a link. this way, the user is less likely to see that something is not quite right. BTW, i'd love to see a similar feature for links to disabled CMSMS pages (instead of a link to homepage).
Locked

Return to “[locked] Installation, Setup and Upgrade”