[SOLVED] Can't move album

pkellum

Joined: 2005-04-13
Posts: 6
Posted: Sun, 2005-04-17 19:27

I get the following error message when trying to move an album to another sub-album.

Warning: rename(E:\gallery\albums\useralbums\pkellum\Patrick-Jr-200504\,E:\gallery\albums\useralbums\pkellum\patrickjr\/Patrick-Jr-200504): No such file or directory in c:\www\html\modules\gallery2\modules\core\classes\GalleryPlatform.class on line 455

----

Gallery URL (optional):
Gallery version: CVS
Webserver (with version): Apache 1.3
Datatabase (with version): MySQL 3.23.49
PHP version (eg 4.2.1): 4.3.9
phpinfo URL (optional): http://familytreeworld.com/info.php
Graphics Toolkit(s): ImageMagik, GD
Operating system: Windows XP Pro
Web browser/version: FireFox 1.0.3
G1 version (for migration bugs):

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-17 20:10

i guess you have found there a bug.
GalleryFileSystemEntity::move

current code

list ($ret, $newPathComponent) =
	    GalleryCoreApi::getLegalPathComponent($this->getPathComponent(), $newParentId);
	if ($ret->isError()) {
	    return $ret->wrap(__FILE__, __LINE__);
	}

	list ($ret, $currentPath) = $this->fetchPath();
	if ($ret->isError()) {
	    return $ret->wrap(__FILE__, __LINE__);
	}

	list ($ret, $newParentPath) = $newParent->fetchPath();
	if ($ret->isError()) {
	    return $ret->wrap(__FILE__, __LINE__);
	}

	/* No collision -- proceed! */
	$ret = parent::move($newParentId);
	if ($ret->isError()) {
	    return $ret->wrap(__FILE__, __LINE__);
	}

	if (!$this->isLinked()) {
	    $newPath = $newParentPath . '/' . $newPathComponent;
	    $platform = $gallery->getPlatform();
	    if (!$platform->rename($currentPath, $newPath)) {
		return GalleryStatus::error(ERROR_BAD_PATH, __FILE__, __LINE__,
					    "rename $currentPath to $newPath");
	    }
	}

by definition, fetchPath() returns a path that is delimited by a platform specific slash, so the additional '/' in the $newPath = $newParentPath . '/' . $newPathComponent should not be there.

now, the question is, why this wasn't detected / covered by unit tests.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-04-17 20:16

pkellum, could you browse to yourgalleryurl/lib/tools/phpunit/index.php?filter=itemmove
(note the itemmove filter in the url)

are all these tests green? this is really important to us to guarantee functionality on windows platforms.
thanks.

and if it is not green, please edit the file
modules/core/classes/GalleryFileSystemEntity.class
about line 261:
change:
$newPath = $newParentPath . '/' . $newPathComponent;
to:
$newPath = $newParentPath . $newPathComponent;
now check the the unit tests again with the itemmove filter.
are all green now?
thanks.

 
pkellum

Joined: 2005-04-13
Posts: 6
Posted: Mon, 2005-04-18 16:37

I tested it and all was green, I changed the code and tested again, still green. But, it now moves the directory properly :)

Thanks!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-04-18 16:55

pkellum, thanks.
I'm fixing it in the source.
The strange thing is, if you use "move test\foo test\/foo" in the windows command line, it ignored the extra slash.
probably php handles it a little differently.

now, all we need is a unit test to expose the problem.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-04-18 21:45

fixed in cvs and a new unit test should expose the problem if someone reintroduces such a typo in this method.