Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

install pecl/apc: constraint failed #60

Open
cweiske opened this issue Aug 19, 2011 · 6 comments
Open

install pecl/apc: constraint failed #60

cweiske opened this issue Aug 19, 2011 · 6 comments
Labels
Milestone

Comments

@cweiske
Copy link
Contributor

cweiske commented Aug 19, 2011

$ ../inst/bin/pyrus-5.3.7 install pecl/apc
Pyrus version 2.0.0a3 SHA-1: BE7EA9D171AE3873F1BBAF692EEE9165BB14BD5D
Using PEAR installation found at /home/cweiske/php/phpfarm/inst/php-5.3.7/pear
Downloading pecl.php.net/APC

Connected...
Mime-type: application/octet-stream

PEAR2\Pyrus\Registry\Exception: Error: package pecl.php.net/APC could not be installed in registry: Unable to execute statement: constraint failed
 Exception: Unable to execute statement: constraint failed
@cweiske
Copy link
Contributor Author

cweiske commented Aug 19, 2011

I added some debug statements (pull please):

Preparing SQL: 
            INSERT INTO configureoptions
              (packages_name, packages_channel, name, prompt, defaultValue)
            VALUES(:name, :channel, :oname, :prompt, :default)
Binding SQL parameter :name: apc
Binding SQL parameter :channel: pecl.php.net
Binding SQL parameter :oname: 
Binding SQL parameter :prompt: 
Binding SQL parameter :default: NULL

@cweiske
Copy link
Contributor Author

cweiske commented Aug 19, 2011

Prompt is NULL, but the SQL creation statement says it may not be null:

Found matching configuration snapshot configsnapshot-2011-08-19 10-51-45.xml
Preparing SQL: 
            INSERT INTO configureoptions
              (packages_name, packages_channel, name, prompt, defaultValue)
            VALUES(:name, :channel, :oname, :prompt, :default)
Binding SQL parameter :name: 'apc'
Binding SQL parameter :channel: 'pecl.php.net'
Binding SQL parameter :oname: NULL
Binding SQL parameter :prompt: NULL
Binding SQL parameter :default: NULL
exception 'Exception' with message 'Unable to execute statement: constraint failed' in /home/cweiske/php/PEAR2_Pyrus/src/Pyrus/Registry/Sqlite3.php:223

@till
Copy link
Member

till commented Nov 13, 2011

I just ran into this too.

What does 'prompt' refer to?

@fpoirotte
Copy link
Member

oname, prompt & default refer to the (PECL-specific) <configureoption> tag in package.xml.

Eg. for APC, package.xml contains:

 <extsrcrelease>
  <configureoption default="no" name="enable-apc-debug" prompt="Enable internal debugging in APC" />
  <configureoption default="no" name="enable-apc-filehits" prompt="Enable per request file info about files used from the APC cache" />
  <configureoption default="no" name="enable-apc-spinlocks" prompt="Enable spin locks (EXPERIMENTAL)" />
  <configureoption default="no" name="enable-apc-memprotect" prompt="Enable memory protection (EXPERIMENTAL)" />
  <configureoption default="yes" name="enable-apc-pthreadmutex" prompt="Enable pthread mutexes (default)" />
  <configureoption default="no" name="enable-apc-pthreadrwlocks" prompt="Enable pthread read/write locks (EXPERIMENTAL)" />
 </extsrcrelease>

I think the meaning of each parameter in the SQL query should be pretty clear now.

AFAICT, I think this is triggered by \Pyrus\PackageFile\v2\Configureoption::current() which sets the name, default & prompt to null explicitely when one of them is missing...

@fpoirotte
Copy link
Member

ok, I managed to install APC by doing a few changes in \Pyrus\PackageFile\v2\Release::__get():

-            if (!isset($this->info['configureoption'])) {
-                $info = array();
-            } else {
-                $info = $this->info['configureoption'];
-                if (!is_array($info) || !isset($info[0])) {
-                    $info = array($info);
+            $info = array();
+            if (isset($this->info['configureoption']) &&
+                is_array($this->info['configureoption'])) {
+                foreach ($this->info['configureoption'] as $configureOption) {
+                    if (isset($configureOption['attribs']))
+                        $info[] = $configureOption['attribs'];
+                    else
+                        $info[] = $configureOption;

For some reason, $this->info['configureoption'] receives a different structure during install and uninstall.

During install, the structure is close to a SimpleXML tree, mapped into an array (eg. with an "attribs" key containing an array of XML attribute => XML value). This looks like this:

$configureoptions = array(
  0 => array(
    "attribs" => array(
      "name" => "...",
      "default" => "...",
      "prompt" => "...",
    )
  ),
  // other options
);

During uninstall, the structure is simpler, there is no intermediary "attribs" sub-array:

$configureoptions = array(
  0 => array(
    "name" => "...",
    "default" => "...",
    "prompt" => "...",
  ),
  // other options
);

Note: even after that change, APC won't build. I still need to investigate that.

@cweiske
Copy link
Contributor Author

cweiske commented Dec 3, 2013

Happes with pecl/memcache, too.

Preparing SQL: 
            INSERT INTO configureoptions
              (packages_name, packages_channel, name, prompt, defaultValue)
            VALUES(:name, :channel, :oname, :prompt, :default)
Binding SQL parameter :name: 'memcache'
Binding SQL parameter :channel: 'pecl.php.net'
Binding SQL parameter :oname: NULL
Binding SQL parameter :prompt: NULL
Binding SQL parameter :default: NULL

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

No branches or pull requests

3 participants