Yourls: Call to undefined function yourls_nonce_url()

Created on 24 Apr 2020  路  15Comments  路  Source: YOURLS/YOURLS

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 );
}
bug

Most helpful comment

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)

All 15 comments

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)

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.

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

I鈥榲e 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

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.

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?

  • 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.

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!

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 (fd4b9278084ea)

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.

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...).

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.

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.

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.

Pinned to aid visibility.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wefixit-AT picture wefixit-AT  路  5Comments

sirtet picture sirtet  路  6Comments

youradds picture youradds  路  3Comments

jonathandhn picture jonathandhn  路  6Comments

LeoColomb picture LeoColomb  路  3Comments