phar_request_initialize(TSRMLS_C);
zend_hash_add(&(PHAR_GLOBALS->phar_fname_map), mydata->fname, fname_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
if (register_alias) {
- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ if (FAILURE == zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL)) {
+ if (options & REPORT_ERRORS) {
+ if (error) {
+ spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias);
+ }
+ }
+ return FAILURE;
+ }
}
return SUCCESS;
}
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
+try {
+ $b = new Phar(dirname(__FILE__) . '/nope.phar', 0, 'test');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
?>
===DONE===
--CLEAN--
hio
test
alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives
+archive "%snope.phar" cannot be associated with alias "test", already in use
===DONE===