Jump to content

Upgrade option for a new version of app


Adriano Faria

Recommended Posts

Posted

@Mark, I'm trying to add an option when updating to latest version of my app but it's not working. That's what I got:

- Created a file called options.php in app/setup/upg_210001/ with the following content:

$options = array();
$options[] = new \IPS\Helpers\Form\YesNo( '210001_fied_name', FALSE );

Then on app/setup/upg_210001/upgrade.php I got:

	public function step2()
	{
        	if ( $_SESSION['upgrade_options']['app']['210001']['field_name'] )
        	{
			//do something
		}
        
        	return TRUE;
	}

But it upgrades from version 210000 to 210001 without show the form.

Am I forgetting something ?

Tks.

Posted
On 29/10/2015 11:01:27, Adriano Faria said:

@Mark, I'm trying to add an option when updating to latest version of my app but it's not working. That's what I got:

- Created a file called options.php in app/setup/upg_210001/ with the following content:


$options = array();
$options[] = new \IPS\Helpers\Form\YesNo( '210001_fied_name', FALSE );

Then on app/setup/upg_210001/upgrade.php I got:


	public function step2()
	{
        	if ( $_SESSION['upgrade_options']['app']['210001']['field_name'] )
        	{
			//do something
		}
        
        	return TRUE;
	}

But it upgrades from version 210000 to 210001 without show the form.

Am I forgetting something ?

Tks.

Anyone?

Posted
$options = array();
$options[] = new \IPS\Helpers\Form\YesNo( '210001_fied_name', FALSE );

 

i dont think it is related but you got spelling mistake on the field name it is 210001_fied_name missing L

 

 

Posted
1 minute ago, Ali Majrashi said:

i dont think it is related but you got spelling mistake on the field name it is 210001_fied_name missing L

Oh yes, a typo because I replaced the real name by that to post here. Tks. :thumbsup:

  • 2 weeks later...
Posted

@Lindy, this would be a good topic to move to the new forum. I really need to run some routines when upgrading app to a new version but I want to give the admin the option to do it.

It should appear a form just like when you upgrade from IP.Board 3 to IPS4, where the admins has options to choose like display/login name, questions forums, etc.

Tks.

Posted

That should indeed work fine. Check what the value is for the "app_long_version" column in the "core_applications" table. It has to be less than the version your options.php file is set to (so only the appropriate options show) and if you've been using the same database for development, it may have updated already.

Posted
23 minutes ago, Mark said:

That should indeed work fine. Check what the value is for the "app_long_version" column in the "core_applications" table. It has to be less than the version your options.php file is set to (so only the appropriate options show) and if you've been using the same database for development, it may have updated already.

Ok, I'll check it out. Tks.

  • 3 months later...
Posted

Ok, @Mark, came back to this today because I'm not sure why, some upgrades from 3.4 didn't ran the text parser, so it appears bbcodes, images links, etc., on tutorials content. So I want to give the admin the option to run it again.

That's what I'm doing:

2 boards install, one dev board with the options, set to version 210003. Other install with version 210002.

On dev board board I got on 210003 version:

  • options.php
  • upgrade.php

Content:

- options.php:

<?php

$options = array();
$options[] = new \IPS\Helpers\Form\YesNo( '210003_run_upgrader', FALSE, FALSE );

- upgrade.php:

class _Upgrade
{
	/**
	 * ...
	 *
	 * @return	array	If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops)
	 */
	public function step1()
	{
        if ( $_SESSION['upgrade_options']['tutorials']['210003']['run_upgrader'] )
        {
			echo time();
			exit;
		}

		return TRUE;
	}
}

I really just want to make the form appears to see it working.

- Built the app and downloaded the .tar.

---------------------------

Now, the other board, which I will test the upgrade, is running the version 210002 from the app, so it should work.

Thing is, it runs the upgrader without stop and show the form.

See: http://www.screencast.com/t/no25UpCT

Posted
On 22/02/2016 at 1:06 PM, Adriano Faria said:

So how can I start a task manually ?

Need to run the same task that runs when you upgrade the app to parse content.

I can't run this on a new version because only a few users who came from 3.4 needs it.

@Mark

Posted
On 22/02/2016 at 1:06 PM, Adriano Faria said:

So how can I start a task manually ?

Need to run the same task that runs when you upgrade the app to parse content.

I can't run this on a new version because only a few users who came from 3.4 needs it.

Ran manually on a new module:

	protected function manage()
	{
	   \IPS\Task::queue( 'core', 'RebuildPosts', array( 'class' => 'IPS\tutorials\Article' ), 2 );
	   \IPS\Task::queue( 'core', 'RebuildPosts', array( 'class' => 'IPS\tutorials\Article\Comment' ), 2 );
	   \IPS\Task::queue( 'core', 'RebuildNonContentPosts', array( 'extension' => 'tutorials_Categories' ), 2 );
	}

 

  • 1 month later...
Posted

I'm not sure I fully follow which task you need to restart, but assuming you mean one of the background tasks it would be something like this

\IPS\Task::queue( 'core', 'RebuildPosts', array( 'class' => 'IPS\forums\Topic\Post' ), 2 );

 

WARNING: most background tasks should not be re-ran without good reason. The above can break your post content, for instance, as it's expecting the content to be in the 3.x format. That said, this is generally how you do it - replacing the task and any variables the task class needs, as appropriate.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...