Skip to content

[#33612] Add a extension installer script feature#3447

Merged
Kubik-Rubik merged 22 commits intojoomla:stagingfrom
wilsonge:extensionscript
May 7, 2016
Merged

[#33612] Add a extension installer script feature#3447
Kubik-Rubik merged 22 commits intojoomla:stagingfrom
wilsonge:extensionscript

Conversation

@wilsonge
Copy link
Copy Markdown
Contributor

@wilsonge wilsonge commented Apr 14, 2014

http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33612&start=0

Feature Basics

This is a helper for developers using install scripts in their extensions it allows you to:

  • Get and set parameters (method getParams and setParam available for this - you can also get all instances of a module with getInstances to help)
  • Stop users from downgrading versions (set allowDowngrades class var to true)
  • Move CLI scripts into the CLI folder (by putting the path to the cli scripts in the class var array)
  • Check for a minimum PHP and Joomla version (by setting the strings for the minimum versions in the relevant class var)
  • Remove out of date files and folders (by putting the path to the files in the class var array)

Usage

Simply by extending the helper class and setting the extension name in the form of com_foobar, mod_foobar etc. in the $this->extension class var

Testing

Try using the feature in extensions - as this is a utility class for developers there's no easy visible effects for user testing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer
Your server does not
to
You don't

@brianteeman
Copy link
Copy Markdown
Contributor

Please alpha sort the new strings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this a bit more. Not sure I understand but from my guess the language string is not "the best"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which string? The final one. It's basically designed to stop people downgrading an extension version - so you can't go from extension v1.5 to 1.4 etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not say something like "Oops it looks like you are trying to install
an older version. You can only use this method to upgrade an extension.

On 15 April 2014 00:23, George Wilson notifications@github.com wrote:

In language/en-GB/en-GB.files_joomla.sys.ini:

@@ -7,4 +7,7 @@ FILES_JOOMLA="Joomla CMS"
FILES_JOOMLA_ERROR_FILE_FOLDER="Error on deleting file or folder %s"
FILES_JOOMLA_ERROR_MANIFEST="Error on updating manifest cache: (type, element, folder, client) = (%s, %s, %s, %s)"

FILES_JOOMLA_XML_DESCRIPTION="Joomla! 3 Content Management System"

+FILES_JOOMLA_ERROR_MOVE="Error on moving file %s"
+JGLOBAL_MINIMUM_PHP="You don't meet the minimum PHP version requirement of %s"
+JGLOBAL_MINIMUM_JOOMLA="You don't meet the minimum Joomla version requirement of J%s"
+JGLOBAL_INCORRECT_SEQUENCE="Incorrect version sequence. Cannot upgrade %s to %s"

Which string? The final one. It's basically designed to stop people
downgrading an extension version

Reply to this email directly or view it on GitHubhttps://github.com//pull/3447/files#r11613485
.

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defined('_JEXEC') or die; without the comment on the previous line

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this REALLY only supposed to be for modules?

Also, the right doc block would be JAdapterInstance (even though we really should have an abstract JInstallerAdapter, maybe I'll pull that out of the installer refactoring branch on the projects repo)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. this is based on the scripts for some of my own modules and I've forgotten to change a few docblocks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference - Use is_file instead of JFile::exists (my rule of thumb is only use JFile for actual write operations)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal preference is to use the abstraction layer whilst it's not deprecated :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists() is something we should have deprecated with everything else in JFile honestly. Only advantage over just calling is_file directly is it calls JPath::clean() on the supplied path.

@wilsonge wilsonge changed the title Add a extension installer script feature [#33612] Add a extension installer script feature Apr 17, 2014
@compojoom
Copy link
Copy Markdown
Contributor

Don't you think that we should find a different name for this class?
the supposed way we should use this is by extending, but extending from a helper class doesn't seem right to me. A helper class should not be extended from - it is normally something that we have just because we have no clue where to put the functionality.
I would actually prefer if you move this to the installer folder and call the class something like installerscriptbase???
Other than that - great! A lot of us have written their own installers. You are covering a lot of things. What would make it even better is if you had plugin, module & library installers there :)
Something like here: https://github.com/compojoom/lib_compojoom/blob/master/source/libraries/compojoom/installer/installer.php#L110

@wilsonge
Copy link
Copy Markdown
Contributor Author

I'm easy as to the name of the class and it's location. Yes you're right it might well be better in libraries/cms/installer.

I considered the library, module and plugin installers but in my opinion core should be persuading people to use packages - they're getting much better in terms of core support since the standardisation we did in 3.4. What do you think?

@mbabker
Copy link
Copy Markdown
Contributor

mbabker commented Jun 27, 2015

@wilsonge see wilsonge#13

The helper class is renamed to JInstallerScript and I've updated 3.4 references to 3.5.

@mbabker
Copy link
Copy Markdown
Contributor

mbabker commented Jun 27, 2015

What would make it even better is if you had plugin, module & library installers there

I tend to agree with @wilsonge on using packages instead of extending a specific adapter to add more extensions. Admittedly there are some weaknesses in the package adapter that need to be worked on to make it more enticing for developers (i.e. one failed extension install aborts the whole thing leaving a partial package install), but I think our focus for core should be moving in that direction.

@joomla-cms-bot joomla-cms-bot added the Language Change This is for Translators label Jun 27, 2015
@roland-d roland-d added this to the Joomla! 3.6.0 milestone Nov 7, 2015
/**
* Base install script for use by extensions providing helper methods for common behaviours.
*
* @since 3.5
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update all since to 3.6

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@joomla-cms-bot
Copy link
Copy Markdown

This PR has received new commits.

CC: @compojoom


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3447.

@joomla-cms-bot
Copy link
Copy Markdown

This PR has received new commits.

CC: @compojoom


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3447.

@Kubik-Rubik
Copy link
Copy Markdown
Member

Thank you @wilsonge, great addition!

@Kubik-Rubik Kubik-Rubik merged commit e05aa66 into joomla:staging May 7, 2016
@wilsonge wilsonge deleted the extensionscript branch May 7, 2016 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants