Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: [Bug]: JUpload and XFeed plugin (1.5.x version, maybe 1.4.x, too)  (Read 11082 times)

0 Members and 1 Guest are viewing this topic.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764

Hi etienne,

I just tested JUpload with cpg1.5.x. As far I can say it works fine, but if you have the plugin 'xfeed' installed, your whole gallery immediately stops to work.

It's because xfeed checks for the global var $album
Code: [Select]
if ((int)$album)
In codebase.php you set
Code: [Select]
$album = getSuperCageInt('album', -1);and later check that value:
Code: [Select]
$album>0
This maybe happens on cpg1.4.x with the appropriate xfeed version, but I haven't tested that.


Suggestion:
change
Code: [Select]
$album = getSuperCageInt('album', -1);to
Code: [Select]
$album = getSuperCageInt('album', false);
and everything works fine.


If this error occurs in cpg1.4.x, too, change that line accordingly
Code: [Select]
$album = isset($_GET['album']) ? (int)$_GET['album'] : -1;
Logged

etienne_sf

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 908
    • Wiki
Re: [Bug]: JUpload and XFeed plugin (1.5.x version, maybe 1.4.x, too)
« Reply #1 on: December 26, 2009, 01:33:50 pm »

Hi thanks for this very clear suggestion,

  I commited it on my SVN. It works under Coppermine 1.4.

  I can't test it under Coppermine 1.5, as I have some strange error each time I update the configuration. I guess I'll have to erase my CPG 1.5 installation and re-install it. Standard upload works nice, and it's ok to test JUpload ... for the moment.

Etienne
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [Bug]: JUpload and XFeed plugin (1.5.x version, maybe 1.4.x, too)
« Reply #2 on: January 12, 2010, 05:38:47 pm »

Actually there is no need to find another name for the SuperCage variable: in Coppermine's core you will find
Code: [Select]
$superCage = Inspekt::makeSuperCage();. It doesn't hurt to re-define that array, so you should use exactly the same array name in your custom code as well.
I have noticed only recently the similar thing in other user contributed plugins: instead of using
Code: [Select]
$superCage = Inspekt::makeSuperCage();plugin authors apparently think that they mustn't use that variable and come up with new array names like
Code: [Select]
$foobar = Inspekt::makeSuperCage();That's not a good idea - always use $superCage.

From the docs (important part highlighted):
Inspekt in Coppermine
Inspekt has been used in CPG by including it in init.inc.php file at the very beginning and creating a supercage immediately after its inclusion.
Code: [Select]
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).PATH_SEPARATOR.'Inspekt');
echo dirname(__FILE__);
require_once "Inspekt.php";

$superCage = Inspekt::makeSuperCage();
Supercage is an aggregation of all the cages, i.e EGPCS (the order of variable parsing). Once the supercage is created none of the EGPCS variables are available.

To access a variable within a supercage we have to use the following format:
Code: [Select]
$qs = $superCage->server->getDigits('QUERY_STRING');
$album = $superCage->get->getInt('album');
$title = $superCage->post->getAlpha('title');
To get an instance of $superCage inside a function use $superCage = Inspekt::makeSuperCage(); again. Do not use the global directive. It may be noted here that makeSuperCage() creates a singleton pattern object. So calling it multiple times does not have any overheads and you can be assured of getting the very same object every time.

Every dev is encouraged to download the latest tarball of Inspekt and checkout the API documentation for the list of available methods for accessing data from cages. In addition to this, there is a bunch of test functions which will test a value of a given key against a pre-determined datatype or format.
I will edit the documentation and add a clarification.
Logged

etienne_sf

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 908
    • Wiki
Re: [Bug]: JUpload and XFeed plugin (1.5.x version, maybe 1.4.x, too)
« Reply #3 on: January 12, 2010, 11:46:08 pm »

Hi,

  I'm not sure if this reply is actually about this thread.


BTW, I learned that I should not make global $superCage; statements.

I removed them almost everywhere.


  I just have a problem now: my plugin is compatible with both CPG1.4 and CPG1.5, by including the relevant include for specific parts.

How can I simply detect that I'm in CPG1.4 or CPG1.5, if I can't just check if $superCage is set ?

Should I also duplicate code in codebase ? 

Etienne
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: [Bug]: JUpload and XFeed plugin (1.5.x version, maybe 1.4.x, too)
« Reply #4 on: January 13, 2010, 08:24:38 am »

You can check COPPERMINE_VERSION.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [Bug]: JUpload and XFeed plugin (1.5.x version, maybe 1.4.x, too)
« Reply #5 on: January 13, 2010, 08:32:36 am »

I'm not sure if this reply is actually about this thread.
it is.


BTW, I learned that I should not make global $superCage; statements.
Correct. And you should not name the cage differently. It doesn't hurt to call the object several times with the same name. That's what I tried to say.

I just have a problem now: my plugin is compatible with both CPG1.4 and CPG1.5, by including the relevant include for specific parts.

How can I simply detect that I'm in CPG1.4 or CPG1.5
That's dead simple: the constant COPPERMINE_VERSION contains the exact coppermine version (see "Developer documentation -> Variables & Constants"). Do a version comparison like this
Code: [Select]
$versionCompare = version_compare($version_number_to_compare_against,COPPERMINE_VERSION);
            if ($versionCompare == 0) {
                $better = 'YES';
            } else {
                $better = 'NO';
            }
There have been complaints in the past that previous versions of coppermine (up to cpg1.4.x) came without dev docs - that's what has changed for cpg1.5.x: a lot of time and effort has gone into the developer documentation of cpg1.5.x - please use it, we really worked hard on it, so we expect long time contributors to read up what we have written down there! Suggestions how to improve it are welcome.
However, your issues with version comparison should not be discussed on this thread. Αndré reported an issue in your code. If you need to discuss coding for cpg1.5.x, you should not use this thread, but the board dedicated to such issues both for your own benefit as well as for the benefit of others. Keeps this thread less cluttered as well and avoids thread drift.
Logged

etienne_sf

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 908
    • Wiki
Re: [Bug]: JUpload and XFeed plugin (1.5.x version, maybe 1.4.x, too)
« Reply #6 on: January 13, 2010, 12:18:18 pm »

There have been complaints in the past that previous versions of coppermine (up to cpg1.4.x) came without dev docs - that's what has changed for cpg1.5.x: a lot of time and effort has gone into the developer documentation of cpg1.5.x - please use it, we really worked hard on it, so we expect long time contributors to read up what we have written down there! Suggestions how to improve it are welcome.

 Yep, thanks for that !

I have to say that I moved forward, without looking for this kind of doc. Sorry for that, I'll read them.

However, your issues with version comparison should not be discussed on this thread. Αndré reported an issue in your code. If you need to discuss coding for cpg1.5.x, you should not use this thread, but the board dedicated to such issues both for your own benefit as well as for the benefit of others. Keeps this thread less cluttered as well and avoids thread drift.

Yep, I stop here.

Thanks for you quote here (Andre and you).

Etienne
Logged
Pages: [1]   Go Up
 

Page created in 0.034 seconds with 20 queries.