Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to undefined function yourls_nonce_url() #2661

Closed
JensSpanier opened this issue Apr 24, 2020 · 15 comments
Closed

Call to undefined function yourls_nonce_url() #2661

JensSpanier opened this issue Apr 24, 2020 · 15 comments
Assignees
Labels
bug

Comments

@JensSpanier
Copy link
Contributor

@JensSpanier JensSpanier commented Apr 24, 2020

Since update to 1.7.9 I get this error:

[24-Apr-2020 11:00:48 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function yourls_nonce_url() in C:\Apache24\htdocs\example.com\www\includes\functions-html.php:528
Stack trace:
#0 C:\Apache24\htdocs\example.com\www\includes\functions.php(295): yourls_table_add_row()
#1 C:\Apache24\htdocs\example.com\www\includes\functions-api.php(21): yourls_add_new_link()
#2 C:\Apache24\htdocs\example.com\www\includes\functions-plugins.php(150): yourls_api_action_shorturl()
#3 C:\Apache24\htdocs\example.com\www\yourls-api.php(35): yourls_apply_filter()
#4 C:\Apache24\htdocs\example.com\www\api.php(26): require_once('C:\\Apache24\\htd...')
#5 {main}
  thrown in C:\Apache24\htdocs\example.com\www\includes\functions-html.php on line 528

api.php looks like this:

// Some recaptcha stuff
// [...]
if ($resp->isSuccess()) {
  define('YOURLS_PRIVATE', false);
  require_once( dirname(__FILE__).'/yourls-api.php' ); // line 26
} else {
  require_once( dirname(__FILE__).'/includes/load-yourls.php' );
  $format = ( isset( $_REQUEST['format'] ) ? $_REQUEST['format'] : 'xml' );
  $return = array(
        'status' => 'fail',
        'code'   => 'error:recaptcha',
        'message' => 'reCAPTCHA not successfull',
        'recaptcha_score' => $resp->getScore(),
        'errorCode' => '403',
      );
  yourls_api_output( $format, $return );
}
@JensSpanier JensSpanier added the bug label Apr 24, 2020
@ozh
Copy link
Member

@ozh ozh commented Apr 24, 2020

Oh, indeed. I moved some functions from one file to another without thinking about guys running a public shortener.

Quick fix until next release: simply add require_once '/path/to/includes/functions-auth.php'; to your config.php
(edit: need to hardcode path)

@sandroshu
Copy link

@sandroshu sandroshu commented Apr 24, 2020

Quick fix until next release: simply add require_once YOURLS_INC.'/functions-auth.php'; to your config.php

I've added it, but got Failed opening required 'YOURLS_INC/functions-auth.php' so I used absolute path and now it works.

@ozh
Copy link
Member

@ozh ozh commented Apr 24, 2020

YOURLS_INC.'/functions-auth.php'. Not 'YOURLS_INC/functions-auth.php'.

@JensSpanier
Copy link
Contributor Author

@JensSpanier JensSpanier commented Apr 24, 2020

I‘ve added require_once YOURLS_INC.'/functions-auth.php'; at the end of my config.php.

But this produces these error messages (YOURLS_INC seems not be defined at this point):

[25-Apr-2020 00:24:06 Europe/Berlin] PHP Warning:  Use of undefined constant YOURLS_INC - assumed 'YOURLS_INC' (this will throw an Error in a future version of PHP) in C:\Apache24\htdocs\example.com\www\user\config.php on line 103
[25-Apr-2020 00:24:06 Europe/Berlin] PHP Warning:  require_once(YOURLS_INC/functions-auth.php): failed to open stream: No such file or directory in C:\Apache24\htdocs\example.com\www\user\config.php on line 103

@ozh
Copy link
Member

@ozh ozh commented Apr 25, 2020

Owww yeah my bad, you're right. You need to include the full path at this point, of course. I'm editing the first comment.

ozh added a commit that referenced this issue Apr 30, 2020
@ozh ozh closed this as completed in fd4b927 May 1, 2020
@acanton77
Copy link

@acanton77 acanton77 commented May 9, 2020

This works in config.php:

require_once( dirname( __DIR__ ).'/includes/functions-auth.php');

Won't this bug wipe out everyone and not just me? Seems like something that should have been fixed ASAP??? Or maybe very few have updated to 1.7.9?

@ozh
Copy link
Member

@ozh ozh commented May 9, 2020

  • 97.1% of YOURLS installs have YOURLS_PRIVATE set to true so it bugs few people actually
  • this has been quickly fixed in master : you can update right now. The master branch is always mostly stable. For the record youlrs.org always run master.

This didn't justify, to me, another release the next day just to fix this.

@acanton77
Copy link

@acanton77 acanton77 commented May 9, 2020

Mr. OZH:

Thank you for your kind attention and for all you do with this system.

It is not fixed in Master. I downloaded the zip 1.7.9 from https://github.com/YOURLS/YOURLS/releases

and the problem happened until I put in the line of of code in config.php.

I understand what you say about access but I don't need to have it private.

What I'm saying is that if you have the config set to:

define( 'YOURLS_PRIVATE', false );

AND you don't have the "require_once" line in config.php

the issue occurs in 1.7.9. Try it!

@ozh
Copy link
Member

@ozh ozh commented May 9, 2020

It's fixed in master, ie the current development code. You've just reinstall the same 1.7.9 that you had already installed.

If you want to fix this without adding the line to your config, download https://github.com/YOURLS/YOURLS/archive/master.zip, which is the 1.7.9 you already have + the commits that have happened since 1.7.9 was released, and in particular the one that fixes the aforementioned problem (fd4b927)

@acanton77
Copy link

@acanton77 acanton77 commented May 9, 2020

I did not know about the "master' .

At the top of the admin screen was a notice saying that 1.7.9 was the latest version and the link took me to https://github.com/YOURLS/YOURLS/releases/tag/1.7.9 and I got the zip from there.

Anyway, 1.7.9 is working fine with the 'require" line in config.php.

I also took your advice and made the system 'private' since that is what most people do. Works fine. Thus, I won't update again and will wait for 1.7.10 or whatever comes next.

Thanks for all your help on this. I wish I had known about YOURLS a long time ago. It works great and is easy to use.

@ozh
Copy link
Member

@ozh ozh commented May 9, 2020

1.7.9 is the latest "release", and "master" refers to the on-going development. Once in a while, we "release" what is on "master" (with a newer version number: 1.7.9, 1.7.10, or 1.8 if we introduce new features, etc...).

@acanton77
Copy link

@acanton77 acanton77 commented May 9, 2020

1.7.9 is the latest "release", and "master" refers to the on-going development.

But since the Admin screen points the user to the 1.7.9 screen and not Master, people (like me) are going to download the 'broken' code. I guess what I was looking for was the 'stable' or 'production' version and I assumed that 1.7.9 was it since that is where I was directed to get the upgrade.

@dgw
Copy link
Member

@dgw dgw commented May 9, 2020

what I was looking for was the 'stable' or 'production' version and I assumed that 1.7.9 was it

It is. Cutting a new release for every bug fix would be pretty annoying for us and for YOURLS admins who'd keep seeing that a new version is available multiple times a month. So we generally don't release a new version until we collect enough fixes to make it worth doing.

This issue affects a small percentage of installs and has a simple workaround, so it's really not worth pushing a new version just for that.

@acanton77
Copy link

@acanton77 acanton77 commented May 9, 2020

I agree that the workaround was simple, but finding it was difficult. Maybe it is posted somewhere besides here and I just didn't find it? I spent quite a bit of time on Google looking for the error message with respect to YOURLS. I thought it might be in the WIKI or on the blog or maybe on the homepage.

I doubt that the average usr would have found it... but perhaps YOURLS is not used by 'average' people and only those with advanced tech knowledge... FTP, code editing skills, etc.

@dgw dgw pinned this issue May 9, 2020
@dgw
Copy link
Member

@dgw dgw commented May 9, 2020

Pinned to aid visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

No branches or pull requests

5 participants