Giter Site home page Giter Site logo

add php 7 support about openstack HOT 10 CLOSED

php-opencloud avatar php-opencloud commented on September 15, 2024
add php 7 support

from openstack.

Comments (10)

nacc avatar nacc commented on September 15, 2024

Hi!
I saw reference to Ubuntu 16.04 in the rackspace/php-opencloud issue regarding PHP7.0 and am actually the individual working on moving PHP7.0 to main in Ubuntu 16.04 (and dropping PHP5 support).

To that end, I hit a bit of an issue now that the version of php-opencloude currently in the 16.04 archive (1.16.0) depends on guzzle/guzzle, which I'd like to remove altogether from the repository (it's EOL and deprecated, as you and others have noted elsewhere). What kind of schedule does 2.0.0 currently have? Would it be reasonable for us to package 2.0.0-rc1 in Ubuntu?

from openstack.

jamiehannaford avatar jamiehannaford commented on September 15, 2024

@nacc I'm pretty happy with the status of 2.0.0-rc1. It supports all of the CORE OpenStack services and has full API declarations, unit tests, sample files, reference docs, user docs and integration tests. I wanted to wait awhile for user feedback before launching a full 2.0.0 release. So this could take another month or two. Before the full release I'd need to do some refactoring (including adding PHP 7 functionality).

If we package 2.0.0-rc1 into 16.04 now, how easy would it be to roll out 2.0.0 when it's fully ready?

from openstack.

nacc avatar nacc commented on September 15, 2024

I'm not sure on that question, but I'll link to this issue from our LP bug and be sure to update once I have a clear answer on it. If the changes are bugfixes, I think it'll be not too big of a deal to update. Just no new features without exception being granted.

from openstack.

nacc avatar nacc commented on September 15, 2024

@jamiehannaford started working on packaging and proposing 2.0.0-RC2 for 16.04.

Ran into some issues, which I can figure out, but noticed you're using https://github.com/phpspec/prophecy-phpunit which is deprecated and not available in Ubuntu. Can you update the src to use phpunit proper?

from openstack.

jamiehannaford avatar jamiehannaford commented on September 15, 2024

@nacc I've just cut a new RC release, including the fix which you mentioned. I want to release v2.0.0 proper next week, which will include:

  • a new dependency on php-opencloud/common that contains common helper classes, ensuring that the Rackspace provider doesn't couple to OpenStack unnecessarily
  • PHP 7 support, including return types etc.

For now though, I think you're good to package RC 3 into 16.04

from openstack.

nacc avatar nacc commented on September 15, 2024

@jamiehannaford Thanks! working on it now. Is there a reason for a reorg from rackspace/php-openstack that had lib/ and lib/OpenCloud but now doesn't?

Also, the old version had a changelog in docs/, is that intentionally not present right now? I guess for a "first" release, it may not matter :)

from openstack.

nacc avatar nacc commented on September 15, 2024

I'm getting a few unit-test failures (note I have to use current HEAD not 2.0.0-RC3 due to the testcases being broken in that tag).

PHPUnit 5.1.3 by Sebastian Bergmann and contributors.

..............E.....E..........................................  63 / 333 ( 18%)
..................EE........................................... 126 / 333 ( 37%)
............................................................... 189 / 333 ( 56%)
............................................................... 252 / 333 ( 75%)
............................................................... 315 / 333 ( 94%)
..................                                              333 / 333 (100%)

Time: 416 ms, Memory: 16.00Mb

There were 4 errors:

1) unit\BlockStorage\v2\ServiceTest::test_it_lists_volumes
InvalidArgumentException: Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON

/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Transport/Utils.php:25
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:47
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:85
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/tests/unit/BlockStorage/v2/ServiceTest.php:80

2) unit\BlockStorage\v2\ServiceTest::test_it_lists_snapshots
InvalidArgumentException: Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON

/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Transport/Utils.php:25
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:47
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:85
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/tests/unit/BlockStorage/v2/ServiceTest.php:167

3) OpenStack\Test\Common\Resource\AbstractResourceTest::test_it_executes_operations_until_a_204_is_received
InvalidArgumentException: Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON

/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Transport/Utils.php:25
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:47
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:85
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/tests/unit/Common/Resource/AbstractResourceTest.php:87

4) OpenStack\Test\Common\Resource\AbstractResourceTest::test_it_invokes_function_if_provided
InvalidArgumentException: Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON

/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Transport/Utils.php:25
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:47
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/src/Common/Resource/Iterator.php:85
/build/php-opencloud-vZ1fuW/php-opencloud-2.0.0~rc3+gitcd025451/tests/unit/Common/Resource/AbstractResourceTest.php:115

FAILURES!
Tests: 333, Assertions: 763, Errors: 4.

This is with

php --version

PHP 7.0.3-9ubuntu1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

from openstack.

nacc avatar nacc commented on September 15, 2024

http://php.net/manual/en/function.json-last-error.php

ah i think one of the comments explains it:

when json_decode a empty string, PHP7 will trigger an Syntax error:
<?php
json_decode("");
var_dump(json_last_error(), json_last_error_msg());

// PHP 7
int(4)
string(12) "Syntax error"

//  PHP 5
int(0)
string(8) "No error"

And officially documented at: php/php-src@9d037d5

from openstack.

nacc avatar nacc commented on September 15, 2024

Something like:

diff --git a/src/Common/Transport/Utils.php b/src/Common/Transport/Utils.php
index c7797be..f85d9bc 100644
--- a/src/Common/Transport/Utils.php
+++ b/src/Common/Transport/Utils.php
@@ -18,7 +18,11 @@ class Utils
             JSON_ERROR_UTF8 => 'JSON_ERROR_UTF8 - Malformed UTF-8 characters, possibly incorrectly encoded'
         ];

-        $data = json_decode((string) $response->getBody(), $assoc);
+        $responseBody = (string) $response->getBody();
+        if (strlen($responseBody) == 0) {
+            return $responseBody;
+        }
+        $data = json_decode($responseBody, $assoc);

         if (JSON_ERROR_NONE !== json_last_error()) {
             $last = json_last_error();

Need a PR?

from openstack.

jamiehannaford avatar jamiehannaford commented on September 15, 2024

@nacc Yes please, that would be great. The only thing I would change is line breaks before and after the if block. Plus === instead of ==. Thanks!

from openstack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.