WordPress.org

Ready to get started?Download WordPress

Forums

Yelp Widget Pro
[resolved] cannot redeclare error (6 posts)

  1. sso7575
    Member
    Posted 8 months ago #

    Hi,

    I installed the Yelp widget but it is conflicting with the Juiz Last Tweet Widget. I am getting cannot re-declare the authentication classes from the oauth file. I tried to comment out what it was complaining about but it just jumps down the next on and complains about it. This is a great plug-in I would really like to use. Any ideas?

    Thanks!

    http://wordpress.org/plugins/yelp-widget-pro/

  2. Devin Walker
    Member
    Plugin Author

    Posted 7 months ago #

    Sorry for the late reply. I will check into this conflict. Just curious, have you tried Twitter Widget Pro?

  3. flaviodj
    Member
    Posted 7 months ago #

    It is because the same class has already been instated.
    An easy fix would (for future proofing against other widgets/plugins using the yelp oauth api), (for the dev)
    go into the "lib/" folder
    Find the file
    oauth.php
    find the code

    Line 7: class OAuthException extends Exception {
    Line 13: class OAuthConsumer {
    Line 29: class OAuthToken {
    Line 49: OAuthUtil::urlencode_rfc3986($this->key) .
    Line 51: OAuthUtil::urlencode_rfc3986($this->secret);
    Line 63: abstract class OAuthSignatureMethod {
    Line 104: class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
    Line 118: $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
    Line 131: class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
    Line 151: $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
    Line 167: abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
    Line 227: class OAuthRequest {
    Line 238: $parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
    Line 265: $request_headers = OAuthUtil::get_headers();
    Line 268: $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
    Line 286: $header_parameters = OAuthUtil::split_header(
    Line 294: return new OAuthRequest($http_method, $http_url, $parameters);
    Line 302: $defaults = array("oauth_version" => OAuthRequest::$version,
    Line 303: "oauth_nonce" => OAuthRequest::generate_nonce(),
    Line 304: "oauth_timestamp" => OAuthRequest::generate_timestamp(),
    Line 311: return new OAuthRequest($http_method, $http_url, $parameters);
    Line 355: return OAuthUtil::build_http_query($params);
    Line 372: $parts = OAuthUtil::urlencode_rfc3986($parts);
    Line 419: return OAuthUtil::build_http_query($this->parameters);
    Line 428: $out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
    Line 431: $out = 'Authorization: OAuth';
    Line 437: throw new OAuthException('Arrays not supported in headers');
    Line 440: $out .= OAuthUtil::urlencode_rfc3986($k) .
    Line 442: OAuthUtil::urlencode_rfc3986($v) .
    Line 488: class OAuthServer {
    Line 571: throw new OAuthException("OAuth version '$version' not supported");
    Line 580: $signature_method = $request instanceof OAuthRequest
    Line 587: throw new OAuthException('No signature method parameter. This parameter is required');
    Line 593: throw new OAuthException(
    Line 606: $consumer_key = $request instanceof OAuthRequest
    Line 611: throw new OAuthException("Invalid consumer key");
    Line 616: throw new OAuthException("Invalid consumer");
    Line 626: $token_field = $request instanceof OAuthRequest
    Line 634: throw new OAuthException("Invalid $token_type token: $token_field");
    Line 645: $timestamp = $request instanceof OAuthRequest
    Line 648: $nonce = $request instanceof OAuthRequest
    Line 666: throw new OAuthException("Invalid signature");
    Line 676: throw new OAuthException(
    Line 684: throw new OAuthException(
    Line 696: throw new OAuthException(
    Line 708: throw new OAuthException("Nonce already used: $nonce");
    Line 715: class OAuthDataStore {
    Line 742: class OAuthUtil {
    Line 774: $params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
    Line 840: $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
    Line 841: $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
    Line 865: $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
    Line 866: $values = OAuthUtil::urlencode_rfc3986(array_values($params));

    Replacce the "OAuth..." with say "YWPOAuth..." like this:

    Line 7: class YWPYWPOAuthException extends Exception {
    Line 13: class YWPYWPOAuthConsumer {
    Line 29: class YWPYWPOAuthToken {
    Line 49: YWPOAuthUtil::urlencode_rfc3986($this->key) .
    Line 51: YWPOAuthUtil::urlencode_rfc3986($this->secret);
    Line 63: abstract class YWPOAuthSignatureMethod {
    Line 104: class YWPOAuthSignatureMethod_HMAC_SHA1 extends YWPOAuthSignatureMethod {
    Line 118: $key_parts = YWPOAuthUtil::urlencode_rfc3986($key_parts);
    Line 131: class YWPOAuthSignatureMethod_PLAINTEXT extends YWPOAuthSignatureMethod {
    Line 151: $key_parts = YWPOAuthUtil::urlencode_rfc3986($key_parts);
    Line 167: abstract class YWPOAuthSignatureMethod_RSA_SHA1 extends YWPOAuthSignatureMethod {
    Line 227: class YWPOAuthRequest {
    Line 238: $parameters = array_merge( YWPOAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
    Line 265: $request_headers = YWPOAuthUtil::get_headers();
    Line 268: $parameters = YWPOAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
    Line 286: $header_parameters = YWPOAuthUtil::split_header(
    Line 294: return new YWPOAuthRequest($http_method, $http_url, $parameters);
    Line 302: $defaults = array("YWPOAuth_version" => YWPOAuthRequest::$version,
    Line 303: "YWPOAuth_nonce" => YWPOAuthRequest::generate_nonce(),
    Line 304: "YWPOAuth_timestamp" => YWPOAuthRequest::generate_timestamp(),
    Line 311: return new YWPOAuthRequest($http_method, $http_url, $parameters);
    Line 355: return YWPOAuthUtil::build_http_query($params);
    Line 372: $parts = YWPOAuthUtil::urlencode_rfc3986($parts);
    Line 419: return YWPOAuthUtil::build_http_query($this->parameters);
    Line 428: $out = 'Authorization: YWPOAuth realm="' . YWPOAuthUtil::urlencode_rfc3986($realm) . '"';
    Line 431: $out = 'Authorization: YWPOAuth';
    Line 437: throw new YWPOAuthException('Arrays not supported in headers');
    Line 440: $out .= YWPOAuthUtil::urlencode_rfc3986($k) .
    Line 442: YWPOAuthUtil::urlencode_rfc3986($v) .
    Line 488: class YWPOAuthServer {
    Line 571: throw new YWPOAuthException("YWPOAuth version '$version' not supported");
    Line 580: $signature_method = $request instanceof YWPOAuthRequest
    Line 587: throw new YWPOAuthException('No signature method parameter. This parameter is required');
    Line 593: throw new YWPOAuthException(
    Line 606: $consumer_key = $request instanceof YWPOAuthRequest
    Line 611: throw new YWPOAuthException("Invalid consumer key");
    Line 616: throw new YWPOAuthException("Invalid consumer");
    Line 626: $token_field = $request instanceof YWPOAuthRequest
    Line 634: throw new YWPOAuthException("Invalid $token_type token: $token_field");
    Line 645: $timestamp = $request instanceof YWPOAuthRequest
    Line 648: $nonce = $request instanceof YWPOAuthRequest
    Line 666: throw new YWPOAuthException("Invalid signature");
    Line 676: throw new YWPOAuthException(
    Line 684: throw new YWPOAuthException(
    Line 696: throw new YWPOAuthException(
    Line 708: throw new YWPOAuthException("Nonce already used: $nonce");
    Line 715: class YWPOAuthDataStore {
    Line 742: class YWPOAuthUtil {
    Line 774: $params[$h] = YWPOAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
    Line 840: $parameter = YWPOAuthUtil::urldecode_rfc3986($split[0]);
    Line 841: $value = isset($split[1]) ? YWPOAuthUtil::urldecode_rfc3986($split[1]) : '';
    Line 865: $keys = YWPOAuthUtil::urlencode_rfc3986(array_keys($params));
    Line 866: $values = YWPOAuthUtil::urlencode_rfc3986(array_values($params));

    now go into the file in the root of the plugin widget.php

    find this:

    Line 45: $token = new OAuthToken($yelp_widget_token, $yelp_widget_token_secret);
    Line 51: $consumer = new OAuthConsumer($yelp_widget_consumer_key, $yelp_widget_consumer_secret);
    Line 54: $signature_method = new OAuthSignatureMethod_HMAC_SHA1();
    Line 98: $oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url, $urlparams);
    Line 98: $oauthrequest = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url, $urlparams);

    replace it by:

    Line 45: $token = new YWPOAuthToken($yelp_widget_token, $yelp_widget_token_secret);
    Line 51: $consumer = new YWPOAuthConsumer($yelp_widget_consumer_key, $yelp_widget_consumer_secret);
    Line 54: $signature_method = new YWPOAuthSignatureMethod_HMAC_SHA1();
    Line 98: $oauthrequest = YWPOAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url, $urlparams);
    Line 98: $oauthrequest = YWPOAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $unsigned_url, $urlparams);

    That should take care of any other class conflicts, even if someone alters the oauth.php in another plugin

  4. Devin Walker
    Member
    Plugin Author

    Posted 7 months ago #

    Thanks - will look into this for a future release!

  5. Devin Walker
    Member
    Plugin Author

    Posted 2 months ago #

    I haven't forgotten about this request!

  6. Devin Walker
    Member
    Plugin Author

    Posted 1 week ago #

    This is fixed as of the latest release. Setting as resolved.

Reply

You must log in to post.

About this Plugin

About this Topic