Laminas migration symlink problem

We run an application which works for 32 websites. That means that we have 32 different configurations. In each of these config folders under autoload there is a symlink pointing to a file outside the app.

The laminas migration fails with this file. The error message per symlink:
Notice: file_get_contents(): read of 8192 bytes failed with errno=21 Is a directory in /…/.composer/vendor/laminas/laminas-migration/src/MigrateProject.php on line 67

The migration then creates a folder containing the symlinked file for each configuration. It is removed from the original location and moved to this new folder in the application root.

I’ve solved the problem by deleting all folders created by the laminas-migration and put the symlinked files back to their original location.

It looks like the migration tries to perform a replacement on this symlink. I’m only testing locally at the moment. It would be nice if this bug would be fixed.

Peter

1 Like

Hey Peter,

I’d suggest starting with an upstream patch with just a failing test case.

In the same app in the public folder we have a symlink to an img folder outside the app. this folder has been completely deleted by the migration! i.e. the folder and all images it contains.

There are two more symlinks in the public folder. But these symlinks are pointing to folders which are inside the app. They were not deleted. Only the folder which the symlink points to a folder outside the app was deleted.

So it looks like the migration can’t handle symlinks which point to a folder or a file outside the app.

Can you provide a bit more information, please?

  • What were the names of the symlinks?
  • Were they absolute or relative paths?

The migration tooling is setup to do the following:

  • Remove the composer.lock and vendor/ subdirectory.
  • Rename files that contain strings in our replacement list.

Thus the reason for my questions — I’m curious if the symlink names contained one of those strings.

We need this information so we can try and reproduce the issue, which is the first step towards creating a fix for it.

We had two problems.

The first in the config folder under autoload. A symlink to a file called “navigation.global.php”. The symlink name is navigation-de.global.php. It’s an absolute path.

The second is a symlink to a folder called “img-dyn”. The symlink name is img-dyn. And here it is a relative path.

Where was the second symlink located? And was the relative path inside our outside the project? (Trying to get as specific as possible so we can reproduce accurately.)

The second symlink is located in the public folder with a relative path outside the project:
…/…/another-project/public/img-dyn

The first one is located in the config folder with a absolute path outside the project:
/Users/username/www/project/data/shared/cms/project-name/navigation/de/navigation.global.php
Since we provide several websites with this app, it should be mentioned that the config folder is a subfolder of the config folder:
/project/config/config-project-name/autoload/symlink-to-file
/project/config/config-another-project-name/autoload/symlink-to-file …

To test this, I did the following:

  • I went into my $HOME/tmp directory
  • I created a directory named another-project/img-dyn
  • I created two files under another-project/img-dyn
  • I created a file navigation-de.global.php
  • I ran composer create-project zendframework/skeleton-application project, and chose defaults.
  • I ran cd project/config/autoload && ln -s $HOME?tmp/navigation-de.global.php navigation.global.php
  • I ran cd project/public && ln -s ../../another-project/img-dyn
  • I ran cd project && laminas-migration migrate .

When I was done, the symlinks were still present, as were the original targets. The files under $HOME/tmp/another-project/img-dyn were still present.

What I did see, however, were two warnings from PHP during the migration for rename() operations for those two symlinks, indicating that the img-dyn directory was not empty, and that when trying to rename the navigation.global.php file it was “Not a directory”.

I suspect that the issues you are seeing are OS specific; however, the errors I saw should likely be addressed. I’ll create a ticket and link you to it.

1 Like

I’ve created the issue here: https://github.com/laminas/laminas-migration/issues/36

1 Like