contao / contao-manager

Contao Manager
GNU Lesser General Public License v3.0
83 stars 33 forks source link

Contao Version is supported #759

Closed katgirl closed 1 year ago

katgirl commented 1 year ago

Contao Manger 1.6.3 PHP 8.2 Contao 5.0.10

When I call /contao-manager.phar.php/api/server/contao then I get the correct Contao version back but unfortunately still the hint that the version is supported. What according to https://github.com/contao/contao-manager/blob/1.6.3/api/TaskOperation/Composer/CreateProjectOperation.php#L27 should not be.

    [version] => 5.0.10
    ...
    [supported] => 1
    [conflicts] => Array
        (
        )
    [project_dir] => /var/customers/webs/xxx/xxx.de
    [public_dir] => public
    [directory_separator] => /
aschempp commented 1 year ago

Looks correct to me 😉

https://contao.github.io/contao-manager/api/index.html#tag/Server-Configuration/paths/~1api~1server~1self-update/get

Bildschirmfoto 2023-02-23 um 08 18 38

aschempp commented 1 year ago

ah sorry, wrong endpoint, but still: the flag tells whether this Contao version is supported (3.5 would not be), not whether this is an option to be installed.

katgirl commented 1 year ago
#!/usr/bin/php
<?php

# Source
# 

$shortopts  = "";
$shortopts .= "H:";  // Hostname
$shortopts .= "T:";  // Token
$shortopts .= "s";   // SSL
$shortopts .= "c";   // no contao-manager via href
$shortopts .= "p";   // perfdata output
$longopts = array(
  "help"
);

$options = getopt($shortopts, $longopts);

if(array_key_exists("help",$options)){
  echo "HELP:\n";
  echo " -H hostname (required)\n";
  echo " -T token (required)\n";
  echo " -s SSL\n";
  echo " -c contao-manager via href\n";
  echo " -p perfdata output\n";
  exit(3);
}
if (!function_exists('curl_exec')){
  echo "Please install curl";
  exit(3);
}

if(!array_key_exists("H",$options)){
  echo "Please Specify a Host";
  exit(3);
}

if(!array_key_exists("T",$options)){
  echo "Please Specify a Token";
  exit(3);
}

if(array_key_exists("s",$options)){
  $contao_server = "https://".$options["H"];
}else{
  $contao_server = "http://".$options["H"];
}
$contao_api_url = "$contao_server/contao-manager.phar.php/api";

function error($e){
  echo "Something went wrong: $e";
  exit(3);
}

$headers = array(
  'Content-Type: application/json',
  'Connection: Close',
  'Authorization: Bearer ' . $options["T"],
);  

$curl = curl_init($contao_api_url. '/server/contao');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERAGENT, 'Icinga');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);

try{
  $response = curl_exec ($curl);
  curl_close($curl);
}catch(Exception $e){
  error($e);
}

$arrData = json_decode($response, true);

echo $arrData['version'] . ' => ' . $arrData['supported'] . PHP_EOL;
./check_contao_dev.php -H DOMAIN1 -T TOKEN -s
5.0.10 => 1
./check_contao_dev.php -H DOMAIN2 -T TOKEN -s
4.13.16 => 1

i had expected false with Conato 5.0.10.

fritzmg commented 1 year ago

i had expected false with Conato 5.0.10.

Why? As already explained, this endpoint tells you whether the Contao Manager supports the Contao version.

katgirl commented 1 year ago

Why? As already explained, this endpoint tells you whether the Contao Manager supports the Contao version.

@fritzmg But even then it would have to be wrong. Because according to https://github.com/contao/contao-manager/blob/1.6.3/api/TaskOperation/Composer/CreateProjectOperation.php#L27 the version is not supported by the Contao Manager. So from my point of view it makes no difference if the Contao version is still supported or the Contao Manager supports the Contao version. Because in both cases I would expect the return value FALSE.

fritzmg commented 1 year ago

@fritzmg But even then it would have to be wrong. Because according to https://github.com/contao/contao-manager/blob/1.6.3/api/TaskOperation/Composer/CreateProjectOperation.php#L27 the version is not supported by the Contao Manager.

No, it's not wrong. The endpoint you are referring to tells you whether a Contao version is supported by the Contao Manager. Obvisouly Contao 5.0.10 is supported by the Contao Manager

The code you are showing in your link only relates to the create-project operation.

So from my point of view it makes no difference if the Contao version is still supported or the Contao Manager supports the Contao version. Because in both cases I would expect the return value FALSE.

Why? Contao 5.0.10 is supported by the Contao Manager.

aschempp commented 1 year ago

The Contao Manager supports any Contao Managed Edition (starting with Contao 4.3). It does not support Contao 3.5. That does not mean you can install any Contao version through the create-project task, only the currently available latest versions are available for initial installation. But you can always add the Contao Manager to any other installation, or manually change the requirements later on.