php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59578 Make __construct non final
Submitted: 2011-01-14 12:48 UTC Modified: 2012-06-13 23:24 UTC
From: sylvain dot lecoy at gmail dot com Assigned: jawed (profile)
Status: Closed Package: oauth (PECL)
PHP Version: 5.3.3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sylvain dot lecoy at gmail dot com
New email:
PHP Version: OS:

 

 [2011-01-14 12:48 UTC] sylvain dot lecoy at gmail dot com
Description:
------------
In order to extends the OAuth object, make the constructor 
non final so we can 
redefine __constrcut().

This is useful for framework like drupal, and you can then 
create an OAuthAdapter 
(which extends OAuth pecl) and instantiate it by giving a 
module name.

e.g. new OAuthAdapter("facebook"); consumer_key and secret 
are stored by drupal 
convention so we can skip this step for d?veloppment and 
make the lib very dev-
friendly. (the pattern adapter allows redefinition in case 
the user don't have 
control on his webserver - shared environment for instance).

Here is some code to illustrate a work around, but using 
__construct will be a 
lot better.

I am using 0.99.9 (on windows machine dev) maybe it has been 
changed on 1.0.0 ?

Sylvain Lecoy

Reproduce code:
---------------
class OAuthAdapter extends OAuth implements DrupalOAuthClient {
  private $mModule;

  static function construct($module, $signature_method = NULL, $auth_type = 
NULL) {
    $consumer_key = variable_get($module . '_consumer_key', '');
    $consumer_secret = variable_get($module . '_consumer_secret', '');
    $oauth = new OAuthAdapter($consumer_key, $consumer_secret, 
$signature_method, $auth_type);
    $oauth->mModule = $module;

    // If the user is not anonymous (can happen with cron auto-sync tasks).
    if ($GLOBALS['user']->uid != 0) {
      $oauth->setCaller($GLOBALS['user']->uid);
    }

    return $oauth;
  }
}

Expected result:
----------------
class OAuthAdapter extends OAuth implements 
DrupalOAuthClient {
  private $mModule;

  function __construct($module, $signature_method = NULL, 
$auth_type = 
NULL) {
    $this->mModule = $module;
    $consumer_key = variable_get($module . '_consumer_key', 
'');
    $consumer_secret = variable_get($module . 
'_consumer_secret', '');
    parent::__construct($consumer_key, $consumer_secret, 
$signature_method, $auth_type);

    // If the user is not anonymous (can happen with cron 
auto-sync tasks).
    if ($GLOBALS['user']->uid != 0) {
      $this->setCaller($GLOBALS['user']->uid);
    }
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-14 13:19 UTC] jawed@php.net
I think this is a valid use case. Any objections to non-final'ing 
OAuth::__construct?

- JJ
 [2011-01-15 20:34 UTC] jawed@php.net
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

This will be in the next release...please help us test your 
particular use case while its in trunk.

- JJ
 [2011-01-15 23:08 UTC] sylvain dot lecoy at gmail dot com
Thanks for the quick reply.

I let you know as soon as I compile a windows version of the 
trunk to test :)
 [2011-02-27 01:03 UTC] sylvain dot lecoy at gmail dot com
It still not work. With OAuth 1.1.1 
(http://downloads.php.net/pierre/) I got the same error while 
override the constructor.

"Cannot override final method OAuth::__construct()"
 [2011-03-01 22:59 UTC] jawed@php.net
Can you please try this in trunk?

- JJ
 [2011-03-02 00:42 UTC] sylvain dot lecoy at gmail dot com
I can't i'm using a version that Pierre compiled on windows. 
If you can give me tips to compile it on windows I would love 
to test it for you and give you feedback.
 [2011-04-12 15:52 UTC] sylvain dot lecoy at gmail dot com
The trunk works great.

I can overrides the constructor which is not final anymore.

I let you close the ticket, for me everything is fine now. 
Thank you.

By the way if you plan to release with this fix don't 
hesitate.
 [2011-04-12 16:05 UTC] sylvain dot lecoy at gmail dot com
Also, why the stable release as tagged with -dev suffix when 
checking with the phpversion() function.

For instance on the live server I fetched last stable 
extension but the output of phpversion('oauth') still displays 
1.0-dev. It should be 1.1.0 shouldn't it ?
 [2011-04-12 16:30 UTC] sylvain dot lecoy at gmail dot com
A last thing there is actually a bug version in the trunk.

The phpversion returns "1.1.1-dev" and not 1.1.1-dev, there is 
double quotes which are messing the version_compare version.
 [2011-04-12 21:50 UTC] jawed@php.net
Yes it should - will fix for release. Thx for heads up.

- JJ
 [2012-06-13 09:30 UTC] sylvain dot lecoy at gmail dot com
Is this issue resolved ? Did not see any pointer in the changelog and the status is still open. :-)
 [2012-06-13 17:15 UTC] jawed@php.net
Thought it was fixed in this commit:

http://svn.php.net/viewvc/pecl/oauth/trunk/oauth.c?revision=308838&view=markup

Is it not?

- JJ
 [2012-06-13 18:32 UTC] sylvain dot lecoy at gmail dot com
Yes it is solved, but I mean, the ticket status.. Is still open.

What is the workflow in the php community ? Should I close it ? Or it is the 
responsibility of maintainers to do so ?

Sylvain Lecoy
 [2012-06-13 23:24 UTC] jawed@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: jawed
 [2012-06-13 23:24 UTC] jawed@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC