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 Alfred\normalizer_normalize() #104

Closed
XOKP opened this issue Mar 23, 2023 · 9 comments
Closed

Call to undefined function Alfred\normalizer_normalize() #104

XOKP opened this issue Mar 23, 2023 · 9 comments

Comments

@XOKP
Copy link

XOKP commented Mar 23, 2023

If you have a problem with the workflow please answer the following questions.

Are you using the latest version of the workflow?
Yes (4.0.1)

Describe the bug
After updating to 4.0.0 and 4.0.1, the workflow is no longer functional. Typing anything likewise produces no output.

To Reproduce
Steps to reproduce the behavior:

  1. Open Alfred
  2. Type '1 usd'
  3. Nothing happens, and no result is visible.

Expected behavior
A conversion result should be displayed as it was previously, prior to the update to version 4.0.0.

Debug Output
[16:46:07.546] Logging Started...
[16:46:08.804] Calculate Anything[Script Filter] Queuing argument 'usd'
[16:46:08.924] Calculate Anything[Script Filter] Script with argv '(null)' finished
[16:46:08.926] ERROR: Calculate Anything[Script Filter] Code 255: Fatal error: Uncaught Error: Call to undefined function Alfred\normalizer_normalize() in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php:318
Stack trace:
#0 /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/process.php(29): Alfred\cleanQuery('1usd')
#1 Command line code(2): include_once('/Users/xxx/x...')
#2 {main}
thrown in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php on line 318
[16:46:08.928] ERROR: Calculate Anything[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
Fatal error: Uncaught Error: Call to undefined function Alfred\normalizer_normalize() in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php:318
Stack trace:
#0 /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/process.php(29): Alfred\cleanQuery('1usd')
#1 Command line code(2): include_once('/Users/xxx/x...')
#2 {main}
thrown in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php on line 318
[16:46:09.017] Calculate Anything[Script Filter] Queuing argument ''
[16:46:09.099] Calculate Anything[Script Filter] Script with argv '(null)' finished
[16:46:09.105] ERROR: Calculate Anything[Script Filter] Code 255: Fatal error: Uncaught Error: Call to undefined function Alfred\normalizer_normalize() in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php:318
Stack trace:
#0 /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/process.php(29): Alfred\cleanQuery('1')
#1 Command line code(2): include_once('/Users/xxx/x...')
#2 {main}
thrown in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php on line 318
[16:46:09.106] ERROR: Calculate Anything[Script Filter] JSON error: JSON text did not start with array or object and option to allow fragments not set. in JSON:
Fatal error: Uncaught Error: Call to undefined function Alfred\normalizer_normalize() in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php:318
Stack trace:
#0 /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/process.php(29): Alfred\cleanQuery('1')
#1 Command line code(2): include_once('/Users/xxx/x...')
#2 {main}
thrown in /Users/xxx/xxx/Alfred.alfredpreferences/workflows/user.workflow.999883C1-64C9-49A0-966C-AA2CC11C5E92/alfred/Alfred.php on line 318

System information:
MacOS 11.7.1
Alfred 5.0.6
PHP 7.3.29

Additional context
It seems that nothing is working as it should be.

@biati-digital
Copy link
Owner

That's weird, nothing on that part changed from 4.0.0 to 4.0.1, it's exactly the same code.

This seems related to @arvidbjorkstrom PR that was included in 4.0.0, a quick search shows:

Normalizer is part of the [intl extension](http://www.php.net/manual/en/book.intl.php). While it's built by default, that does not necessarily mean that the specific version of PHP that you are using has it installed or enabled by default.

But again you said that it worked in 4.0.0, can you confirm that? did you change your PHP installation?

@XOKP
Copy link
Author

XOKP commented Mar 23, 2023

No, it isn't working in both versions 4.0.0 and 4.0.1. It used to work in 3.5.0 but stopped after updating to 4.0.0, and 4.0.1 didn't fix the issue.

@XOKP
Copy link
Author

XOKP commented Mar 23, 2023

I have not made any changes to my PHP. The issue can be resolved by reverting back to version 3.5.0.

@biati-digital
Copy link
Owner

Oh sorry, i misread your issue, like i mentioned, the issue was introduced by a PR #93 , hopefully the author of that PR @arvidbjorkstrom can help us find a solution and if not possible i'll remove that function to fix the error.

In the meantime you can use 3.5.0 or install the latest version and remove that line, if you want to give it a go please follow this steps

1.- Open the workflow folder
CleanShot 2023-03-23 at 03 43 38

2.- Inside that folder open the file alfred/Alfred.php and remove line 318
$clean = normalizer_normalize($clean);

@XOKP
Copy link
Author

XOKP commented Mar 23, 2023

Thanks a bunch for the quick help! Your detailed steps were helpful.

@arvidbjorkstrom
Copy link

arvidbjorkstrom commented Mar 24, 2023

Hello!

The reason for the call to normalize is to avoid non ascii characters not matching what looks like the same character. For instance "hästkrafter" (horsepower) not matching the seemingly same word because one ä is really made from a combination of two characters (¨ and a in this case).

I see three ways to fix this:

  1. Write code to check if normalizer_normalize exists, and if it does use it, otherwise just let the language files not match making words with non ascii characters not match.
  2. Write code to "normalize" just the special characters used in the language files.
  3. Find an alternative to normalize_normalize that is included in more PHP installations.

@arvidbjorkstrom
Copy link

arvidbjorkstrom commented Mar 28, 2023

@biati-digital If you want to remove the removal of ñ and other Spanish characters and add them to the es_ES-keys.php file I also added normalization for those characters as well.

@akrabat
Copy link

akrabat commented Apr 7, 2023

FWiW, if you're missing normalizer_normalize, that means that your PHP installation doesn't have the intl extension installed/enabled.

Homebrew installations of PHP include it by default, but I don't know if other package managers do. If you are using Macports, you probably need sudo port install php81-intl or sudo port install php82-intl depending on your PHP version.

@biati-digital
Copy link
Owner

Thank's @arvidbjorkstrom for the PR. An update has been released, it should be possible to update directly from Alfred or you can download the latest update from the releases page

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

No branches or pull requests

4 participants