php 8.0

Found a bug? Tell us!!
onli
Regular
Posts: 2725
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: php 8.0

Post by onli »

In the admin backend, go to the plugins area. There are two tabs, one for sidebar, one for event plugins. Spartacus is an event plugin, so select those. Then search spartacus in your plugin list and click on the settings icon on the top right of the spartacus plugin box.

If you are yourself the hoster, it might be that PHP is configured to not allow outgoing connections like that. That could be for example be caused by a disabled `allow_url_fopen` directive I think, when the curl extensions is also disabled. See https://www.php.net/manual/en/filesyste ... ration.php
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

make changes, still getting the block IP address message
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

Just tried again


from my error_logs we see

2022/11/23 19:02:50 [error] 47227#103021: *391188 FastCGI sent in stderr: "PHP message: PHP Warning: chmod(): Operation not permitted in /usr/home/doctor/html/blog/serendipity/bundled-libs/voku/simple-cache/src/voku/cache/AdapterFileAbstract.php on line 104" while reading response header from upstream, client: 216.244.66.248, server: www.nk.ca, request: "GET /%7Edoctor/blog/serendipity/index.php?/archives/2022/02/02.html HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "www.nk.ca"
2022/11/23 19:02:59 [error] 47227#103021: *391218 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to a member function getStatus() on null in /usr/local/www/nginx-dist/blog/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php:458
#0 /usr/local/www/nginx-dist/blog/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(641): serendipity_event_spartacus->fetchfile('https://raw.git...', '/usr/local/www/...', 43200, true)
#1 /usr/local/www/nginx-dist/blog/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(1302): serendipity_event_spartacus->fetchOnline('sidebar')
#2 /usr/local/www/nginx-dist/blog/include/plugin_api.inc.php(1184): serendipity_event_spartacus->event_hook('backend_plugins...', Object(serendipity_property_bag), Array, NULL)
#3 /usr/local/www/nginx-dist/blog/include/admin/plugins.inc.php(160): serendipity_plugin_api::hook_event('backend_plugins...', Array)
#4 /usr/local/www/nginx-dist/blog/serendipity_admin.php(127): include('/usr/local/www/...')
thrown in /usr/local/www/nginx-dist/blog/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php on line 458" while reading response header from upstream, client: 204.209.81.1, server: www.nk.ca, request: "GET /blog/serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE&serendipity[token]=dfcf4a17e14e0559b1a7d9a9eda16252 HTTP/3.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", referrer: "https://www.nk.ca/blog/serendipity_admi ... e]=plugins"
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

I just noted HTTP/3.0 FYI
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

Tried to updat eto 2.4.0
error
and the httpd logs show

2022/11/23 19:17:18 [error] 47227#103021: *393315 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to a member function getBody() on null in /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php:535
#0 /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(653): serendipity_event_spartacus->fetchfile('https://raw.git...', '/usr/home/docto...', 43200, true)
#1 /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(1164): serendipity_event_spartacus->fetchOnline('sidebar')
#2 /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(1340): serendipity_event_spartacus->count_plugin_upgrades()
#3 /usr/home/doctor/html/blog/serendipity/include/plugin_api.inc.php(1188): serendipity_event_spartacus->event_hook('backend_plugins...', Object(serendipity_property_bag), NULL, NULL)
#4 /usr/home/doctor/html/blog/serendipity/include/admin/upgrader.inc.php(457): serendipity_plugin_api: in /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php on line 535" while reading response header from upstream, client: 204.209.81.1, server: www.nk.ca, request: "GET /~doctor/blog/serendipity/serendipity_admin.php HTTP/3.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", referrer: "https://www.nk.ca/~doctor/blog/serendipity/index.php"
onli
Regular
Posts: 2725
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: php 8.0

Post by onli »

Yeah, that's pretty clear: The request is getting blocked, then spartacus gets a null response where it doesn't expect one, and this produces the error you see. So, to recapitulate:

1. You are absolutely certain the server can get a connection to Github? You can login via ssh and do `wget https://raw.github.com/s9y/additional_p ... bar_en.xml`?
2. PHP is not configured to block outgoing connections? What is the setting for allow_url_fopen?
3. Is the PHP curl module installed and active?
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

the wget yield wget --no-check-certificate https://raw.github.com/s9y/additional_p ... bar_en.xml
--2022-11-24 13:14:20--
...

Saving to: 'package_sidebar_en.xml'

package_sidebar_en. 100%[===================>] 151.17K --.-KB/s in 0.02s

2022-11-24 13:14:21 (9.09 MB/s) - 'package_sidebar_en.xml' saved [154794/154794]

root@doctor:/var/spool/ftp # ls
.spamassassin hidden package_sidebar_en.xml
gmon.out incoming pub


2) egrep allow_url_fopen /usr/local/etc/php.ini
allow_url_fopen = On


3) ls *php*
php-fpm.conf php.conf php.ini-development
php-fpm.conf.default php.ini php.ini-production

php:
ext-10-opcache.ini ext-20-intl.ini ext-20-sqlite3.ini
ext-18-session.ini ext-20-json.ini ext-20-sysvmsg.ini
ext-20-bcmath.ini ext-20-ldap.ini ext-20-sysvsem.ini
ext-20-bz2.ini ext-20-mbstring.ini ext-20-sysvshm.ini
ext-20-calendar.ini ext-20-mysqli.ini ext-20-tidy.ini
ext-20-ctype.ini ext-20-odbc.ini ext-20-tokenizer.ini
ext-20-curl.ini ext-20-openssl.ini ext-20-xml.ini
ext-20-dba.ini ext-20-pcntl.ini ext-20-xmlwriter.ini
ext-20-dom.ini ext-20-pdo.ini ext-20-zip.ini
ext-20-enchant.ini ext-20-pgsql.ini ext-20-zlib.ini
ext-20-exif.ini ext-20-phar.ini ext-30-pdf.ini
ext-20-fileinfo.ini ext-20-posix.ini ext-30-pdo_dblib.ini
ext-20-filter.ini ext-20-pspell.ini ext-30-pdo_firebird.ini
ext-20-ftp.ini ext-20-readline.ini ext-30-pdo_mysql.ini
ext-20-gd.ini ext-20-shmop.ini ext-30-pdo_odbc.ini
ext-20-gettext.ini ext-20-simplexml.ini ext-30-pdo_pgsql.ini
ext-20-gmp.ini ext-20-snmp.ini ext-30-pdo_sqlite.ini
ext-20-iconv.ini ext-20-soap.ini ext-30-xmlreader.ini
ext-20-igbinary.ini ext-20-sockets.ini ext-30-xmlrpc.ini
ext-20-imap.ini ext-20-sodium.ini ext-30-xsl.ini

php-fpm.d:
www.conf www.conf.default
root@doctor:/usr/local/etc # less php/ext-20-curl.ini
extension=curl.so

/usr/local/etc # find ../lib -name \*curl.so\* -print
../lib/libcurl.so
../lib/ipsec/plugins/libstrongswan-curl.so
../lib/libleatherman_curl.so.1.12.6
../lib/php/20190902-zts-debug/curl.so
../lib/libcurl.so.4
onli
Regular
Posts: 2725
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: php 8.0

Post by onli »

Is the curl module also loaded? I ask because in some places it is used as a fallback.

But otherwise I'm out of ideas. The spartacus downloads seems to work in the installations I control, which makes me think this has to be a setup thing (maybe really that http3 call?), but I have no further idea what it could be. Maybe someone else sees the problem here?

Ah, one thing: We should test a simple php test file downloading the target url, and that way we see whether it is something in the php configuration. It could use file_open or curl. Do you know how to write that?

If that one works, next step would be to test with the bundled http_request library spartacus is likely using here, and to check before what exactly spartacus does.
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

verified by https://www.nk.ca/phpinfo.phtml and the above curl is loaded! The problem could be with the http/3.0 which I am using with nginx
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

Tell me what to write and I can test it
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

A Curl test yields

curl -v -v -v -v -v -v -v -v -v -v -v -v https://raw.github.com/s9y/additional_p ... bar_en.xml
* STATE: INIT => CONNECT handle 0x801aba808; line 1881 (connection #-5000)
* Added connection 0. The cache now contains 1 members
* STATE: CONNECT => RESOLVING handle 0x801aba808; line 1927 (connection #0)
* family0 == v4, family1 == v6
* Trying 185.199.110.133:443...
* STATE: RESOLVING => CONNECTING handle 0x801aba808; line 2011 (connection #0)
* Connected to raw.github.com (185.199.110.133) port 443 (#0)
* STATE: CONNECTING => PROTOCONNECT handle 0x801aba808; line 2076 (connection #0)
* ALPN: offers h2
* ALPN: offers http/1.1
* CAfile: /usr/local/share/certs/ca-root-nss.crt
* CApath: none
* Didn't find Session ID in cache for host HTTPS://raw.github.com:443
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* STATE: PROTOCONNECT => PROTOCONNECTING handle 0x801aba808; line 2094 (connection #0)
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted h2
* Server certificate:
* subject: C=US; ST=California; L=San Francisco; O=GitHub, Inc.; CN=*.github.io
* start date: Mar 18 00:00:00 2022 GMT
* expire date: Mar 21 23:59:59 2023 GMT
* subjectAltName: host "raw.github.com" matched cert's "*.github.com"
* issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS RSA SHA256 2020 CA1
* SSL certificate verify ok.
* STATE: PROTOCONNECTING => DO handle 0x801aba808; line 2113 (connection #0)
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: GET]
* h2h3 [:path: /s9y/additional_plugins/master/package_sidebar_en.xml]
* h2h3 [:scheme: https]
* h2h3 [:authority: raw.github.com]
* h2h3 [user-agent: curl/7.85.0]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0x801aba808)
> GET /s9y/additional_plugins/master/package_sidebar_en.xml HTTP/2
> Host: raw.github.com
> user-agent: curl/7.85.0
> accept: */*
>
* STATE: DO => DID handle 0x801aba808; line 2193 (connection #0)
* multi changed, check CONNECT_PEND queue
* STATE: DID => PERFORMING handle 0x801aba808; line 2312 (connection #0)
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Didn't find Session ID in cache for host HTTPS://raw.github.com:443
* Added Session ID to cache for HTTPS://raw.github.com:443 [server]
* HTTP/2 found, allow multiplexing
< HTTP/2 301
< location: https://raw.githubusercontent.com/s9y/a ... bar_en.xml
< accept-ranges: bytes
< date: Fri, 25 Nov 2022 23:27:42 GMT
< via: 1.1 varnish
< age: 0
< x-served-by: cache-yyc1430027-YYC
< x-cache: MISS
< x-cache-hits: 0
< x-timer: S1669418862.949493,VS0,VE342
< vary: Accept-Encoding
< x-fastly-request-id: 1768e9f309bed80433544cb01341989f3663e97a
< content-length: 0
<
* STATE: PERFORMING => DONE handle 0x801aba808; line 2511 (connection #0)
* multi_done: status: 0 prem: 0 done: 0
* Connection #0 to host raw.github.com left intact
* Expire cleared (transfer 0x801aba808)
onli
Regular
Posts: 2725
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: php 8.0

Post by onli »

Please try it with this code:

Code: Select all

<?php

$url="https://raw.github.com/s9y/additional_plugins/master/package_sidebar_en.xml";

$curl_session = curl_init(); 
curl_setopt($curl_session ,CURLOPT_URL,$url);
$result = curl_exec($curl_session );
curl_close($curl_session );
if ($result) {
    echo "curl seems to work";
}

sleep(2);

$result = file_get_contents($url);

if ($result) {
    echo "fopen seems to work";
}

sleep(2);

#require_once './bundled-libs/Net/URL2.php';
#require_once './bundled-libs/HTTP/Request2/PEAR/Exception.php';
set_include_path('./bundled-libs/');
require_once './bundled-libs/' . 'HTTP/Request2.php';
$options = array('follow_redirects' => true, 'max_redirects' => 5);

$req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET, $options);
try {
    $response = $req->send();
    if ($response->getStatus() != '200') {
        throw new HTTP_Request2_Exception('Statuscode not 200, Akismet HTTP verification request failed.');
    }
} catch (HTTP_Request2_Exception $e) {
    echo $e;
}

$result = $response->getBody();

if ($result) {
    echo "http_request2 seems to work";
}
This has to be placed in your s9y directory, where the index.php etc ist. What happens when you run it afterwards via your browser?
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

Error

from browser

The URL https://raw.github.com/s9y/additional_p ... bar_en.xml (IP 185.199.110.133) could not be opened. Maybe the Serendipity or SourceForge.net Server is down - we are sorry, you need to try again later.

from logs


2022/11/29 16:30:35 [error] 13537#102373: *2060844 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to a member function getStatus() on null in /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php:458
#0 /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(641): serendipity_event_spartacus->fetchfile('https://raw.git...', '/usr/home/docto...', 43200, true)
#1 /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php(1302): serendipity_event_spartacus->fetchOnline('sidebar')
#2 /usr/home/doctor/html/blog/serendipity/include/plugin_api.inc.php(1184): serendipity_event_spartacus->event_hook('backend_plugins...', Object(serendipity_property_bag), Array, NULL)
#3 /usr/home/doctor/html/blog/serendipity/include/admin/plugins.inc.php(160): serendipity_plugin_api::hook_event('backend_plugins...', Array)
#4 /usr/home/doctor/html/blog/serendipity/serendipity_admin.php(127): include('/usr/home/docto...')
thrown in /usr/home/doctor/html/blog/serendipity/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php on line 458" while reading response header from upstream, client: 204.209.81.1, server: www.nk.ca, request: "GET /~doctor/blog/serendipity/serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[only_group]=UPGRADE&serendipity[token]=992d224425c3a22860dabda4c67cc596 HTTP/3.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", referrer: "https://www.nk.ca/~doctor/blog/serendip ... e]=plugins"
rootnl2k
Regular
Posts: 49
Joined: Tue Jul 17, 2012 7:15 am

Re: php 8.0

Post by rootnl2k »

From CLI

php testcode.php
Failed loading /usr/local/lib/php/20131226-zts-debug/ioncube/ioncube_loader.so: Cannot open "/usr/local/lib/php/20131226-zts-debug/ioncube/ioncube_loader.so"
PHP Warning: PHP Startup: igbinary: Unable to initialize module
Module compiled with module API=20170718
PHP compiled with module API=20190902
These options need to match
in Unknown on line 0
curl seems to work PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /usr/home/doctor/html/blog/serendipity/testcode.php on line 15
PHP Warning: file_get_contents(): Failed to enable crypto in /usr/home/doctor/html/blog/serendipity/testcode.php on line 15
PHP Warning: file_get_contents(https://raw.github.com/s9y/additional_p ... bar_en.xml): failed to open stream: operation failed in /usr/home/doctor/html/blog/serendipity/testcode.php on line 15
HTTP_Request2_ConnectionException: Unable to connect to tls://raw.github.com:443. Error: stream_socket_client(): unable to connect to tls://raw.github.com:443 (Unknown error)
stream_socket_client(): Failed to enable crypto
stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /usr/home/doctor/html/blog/serendipity/bundled-libs/HTTP/Request2/Adapter/Socket.php on line 331
#0 /usr/home/doctor/html/blog/serendipity/bundled-libs/HTTP/Request2/Adapter/Socket.php(331): HTTP_Request2_SocketWrapper->__construct('tls://raw.githu...', 10, Array)
#1 /usr/home/doctor/html/blog/serendipity/bundled-libs/HTTP/Request2/Adapter/Socket.php(128): HTTP_Request2_Adapter_Socket->connect()
#2 /usr/home/doctor/html/blog/serendipity/bundled-libs/HTTP/Request2.php(941): HTTP_Request2_Adapter_Socket->sendRequest(Object(HTTP_Request2))
#3 /usr/home/doctor/html/blog/serendipity/testcode.php(31): HTTP_Request2->send()
#4 {main}PHP Notice: Undefined variable: response in /usr/home/doctor/html/blog/serendipity/testcode.php on line 39
PHP Fatal error: Uncaught Error: Call to a member function getBody() on null in /usr/home/doctor/html/blog/serendipity/testcode.php:39
Stack trace:
#0 {main}
thrown in /usr/home/doctor/html/blog/serendipity/testcode.php on line 39
onli
Regular
Posts: 2725
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: php 8.0

Post by onli »

Opening your testcode.php in browser would still be interesting. Your first answer is the spartacus response again, not the testfile.

Assuming the cli environment is the same as the webserver environment: There seems to be an issue with OpenSSL when using file_get_contents or HTTP_Request2. Spartacus should fall back to curl (and curl seems to work), likely doesn't because that error is not expected. We can try to fix that fallback to curl, but it would likely be worthwhile to fix the server/PHP setup.

Which linux distro are you using? The openssl module is installed? What's the output of `php -i | grep openssl`?
Post Reply