beyondcode / herd-community

91 stars 1 forks source link

[Bug]: Auto Prepend not being respected after updates/restarts #1119

Closed Cazzar closed 4 weeks ago

Cazzar commented 4 weeks ago

Platform

macOS

Operating system version

macOS Sequoia 15.0.1

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.11.1 (Build 34)

PHP Version

No response

Bug description

When setting auto_prepend_file then restarting it, herd will automatically remap it to herd_auto_prepend_file

But, when herd then runs with the auto_prepend_file like this, it does not respect the autoprepend. Setting the auto_prepend_file to something other than the heard defaults does stop the dump() additions, which is not preferred, I have currently managed a workaround by creating a custom auto_prepend_file that does a require of the global one I need, as well as Herd's.

In the steps I have provided just php 8.3 but I have had this issue for 7.4 as well, so I assume it is the same as every file.

Steps to reproduce

Some paths have been truncated for privacy and ease of reading.

Show the setup.

➜ herd-example php -v
PHP 8.3.13 (cli) (built: Oct 25 2024 00:21:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.13, Copyright (c), by Zend Technologies
➜ herd-example php -i | grep "prepend"
auto_prepend_file => /Applications/Herd.app/Contents/Resources/valet/dump-loader.php => /Applications/Herd.app/Contents/Resources/valet/dump-loader.php
error_prepend_string => no value => no value

Application Setup

➜ herd-example cat autoprepend.php
<?php

function my_global_function() {
  return "foo";
}
➜ herd-example cat some-application.php
<?php

die(my_global_function());

Setup auto_prepend_file and confirm.

➜ herd-example echo "auto_prepend_file=$(realpath autoprepend.php)" >> ~/Library/Application\ Support/Herd/config/php/83/php.ini
➜ herd-example php -i | grep "prepend"
auto_prepend_file => .../herd-example/autoprepend.php => .../herd-example/autoprepend.php
error_prepend_string => no value => no value

➜ herd-example php some-application.php
foo%

Restart the herd app

➜ herd-example php -i | grep "prepend"
auto_prepend_file => /Applications/Herd.app/Contents/Resources/valet/dump-loader.php => /Applications/Herd.app/Contents/Resources/valet/dump-loader.php
error_prepend_string => no value => no value

my auto prepend has been reset

➜ herd-example grep "prepend" ~/Library/Application\ Support/Herd/config/php/83/php.ini
auto_prepend_file=/Applications/Herd.app/Contents/Resources/valet/dump-loader.php
herd_auto_prepend_file=.../herd-example/autoprepend.php

it's been set as herd_auto_prepend_file now, hm, okay\ but this never get's loaded.

➜ herd-example php some-application.php

Fatal error: Uncaught Error: Call to undefined function my_global_function() in .../herd-example/some-application.php:3
Stack trace:
#0 {main}
  thrown in .../herd-example/some-application.php on line 3

Relevant log output

No response

mpociot commented 4 weeks ago

Thanks for reporting this, it'll be fixed in tomorrows update!