xoops forums

Lupin

Just popping in
Posted on: 1/16 15:30
Lupin
Lupin (Show more)
Just popping in
Posts: 72
Since: 2007/6/1 2
#1

Cannot enter in PUBLISHER module administration ... but "sometimes" ...

OK, this is really strange ...

Sometimes (without any apparent connection with times or activities ...) we are unable to enter the module administration (version 1.07 final, xoops 2.5.10).
It almost always happens after inserting new categories or items ... but I'm almost sure that it is purely random.
Given the frequency of the problem I activated the debugging and here I report what I read:
1) on the web page: Error : Error: Cannot use object of type stdClass as array
2) in debugging: Errors
Notice: Trying to get property 'tag_name' of non-object in file /modules/publisher/class/Common/VersionChecks.php line 122
Error: Error: Cannot use object of type stdClass as array in file /modules/publisher/class/Common/VersionChecks.php line 123


One question: is it possible to know when the last modification was made to the module?

Thank you

Pino

goffy

Quite a regular
Posted on: 1/16 19:09
goffy
goffy (Show more)
Quite a regular
Posts: 392
Since: 2010/12/27
#2

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...

Hi Pino

it seems that sometimes connection to github is failing.
Please goto file /modules/publisher/class/Common/VersionChecks.php line 122 and add following if-condition:
$file              json_decode($curlReturnfalse);
                    if (
json_last_error() !== JSON_ERROR_NONE) {
                        
curl_close($curlHandle);
                        return [];
                    }


let me know whether this fix your problem.

goffy

Lupin

Just popping in
Posted on: 1/16 19:34
Lupin
Lupin (Show more)
Just popping in
Posts: 72
Since: 2007/6/1 2
#3

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...

TYVM Goffy ,

tomorrow you will have the report.

Pino

Lupin

Just popping in
Posted on: 1/17 15:49
Lupin
Lupin (Show more)
Just popping in
Posts: 72
Since: 2007/6/1 2
#4

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...



Unfortunately the problem has been repeated ... the two errors (the same) have only moved to lines 127 and 128 ...

Quote:
Notice: Trying to get property 'tag_name' of non-object in file /modules/publisher/class/Common/VersionChecks.php line 127 Error: Error: Cannot use object of type stdClass as array in file /modules/publisher/class/Common/VersionChecks.php line 128


Here the mod.

(#100)
public static function checkVerModule($helper$source 'github'$default 'master')
    {
        
$moduleDirName      basename(dirname(dirname(__DIR__)));
        
$moduleDirNameUpper mb_strtoupper($moduleDirName);
        
$update             '';
        
$repository         'XoopsModules25x/' $moduleDirName;
        
//        $repository         = 'XoopsModules25x/publisher'; //for testing only
        
$ret             '';
        
$infoReleasesUrl "https://api.github.com/repos/$repository/releases";
        if (
'github' === $source) {
            if (
function_exists('curl_init') && false !== ($curlHandle curl_init())) {
                
curl_setopt($curlHandleCURLOPT_URL$infoReleasesUrl);
                
curl_setopt($curlHandleCURLOPT_RETURNTRANSFERtrue);
                
curl_setopt($curlHandleCURLOPT_SSL_VERIFYPEERfalse);
                
curl_setopt($curlHandleCURLOPT_HTTPHEADER, ["User-Agent:Publisherrn"]);
                
$curlReturn curl_exec($curlHandle);
                if (
false === $curlReturn) {
                    
trigger_error(curl_error($curlHandle));
                } elseif (
false !== strpos($curlReturn'Not Found')) {
                    
trigger_error('Repository Not Found: ' $infoReleasesUrl);
                } else {
                    
$file              json_decode($curlReturnfalse);
                      
/* nuovo if */
                    
if (json_last_error() !== JSON_ERROR_NONE) {
                        
curl_close($curlHandle);
                        return [];
                    } 
/* fine nuovo if */
                    
$latestVersionLink sprintf("https://github.com/$repository/archive/%s.zip"$file reset($file)->tag_name $default);
                    
$latestVersion     $file[0]->tag_name;
                    
$prerelease        $file[0]->prerelease;
(
#129)

geekwright

Quite a regular
Posted on: 1/17 21:49
geekwright
geekwright (Show more)
Quite a regular
Posts: 296
Since: 2010/10/15
#5

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...

I had not realized the new module code was doing this. Cool feature.

I've got a few thoughts.

Looks like we should be checking the CURLINFO_RESPONSE_CODE with curl_getinfo() to make sure the return is a 200. A lot of other codes can be returned with a valid json body that are totally different than the releases body. An example is the 403 response code for a rate limit exceded error - https://developer.github.com/v3/#rate-limiting

We might also consider a more precise end point, like this:
https://api.github.com/repos/XoopsModu ... publisher/releases/latest

To be good github citizens, we should cache the results for some period of time so we don't generate hundreds of checks while doing publisher setup activities. The period could easily be an hour or more. Xmf\Module\Helper\Cache::cacheRead() could make that easy.

One last observation not directly related to this issue, since publisher can be cloned, it looks like this check will not get any data, or wrong data from another module.

Lupin

Just popping in
Posted on: 1/23 16:50
Lupin
Lupin (Show more)
Just popping in
Posts: 72
Since: 2007/6/1 2
#6

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...

Is anyone working on this problem?
Since yesterday none of the administrators has managed to enter the administration panel of the module !!!
Since we would soon need to go into production, is it possible to have a version without this "automatic data collector"?

Thanks

Pino

Mamba

Moderator
Posted on: 1/23 23:25
Mamba
Mamba (Show more)
Moderator
Posts: 10838
Since: 2004/4/23
#7

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...

Just comment out lines 92-95 in /admin/index.php:

//$newRelease = $utility::checkVerModule($helper);
//if (!empty($newRelease)) {
    //$adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"');
//}
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

Lupin

Just popping in
Posted on: 1/24 19:44
Lupin
Lupin (Show more)
Just popping in
Posts: 72
Since: 2007/6/1 2
#8

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...

TYVM Mamba ,

I will report.

Pino

Lupin

Just popping in
Posted on: 1/30 19:41
Lupin
Lupin (Show more)
Just popping in
Posts: 72
Since: 2007/6/1 2
#9

Re: Cannot enter in PUBLISHER module administration ... but "sometimes" ...

Of course , no more service interruptions !

TY

Pino