Indefero

Issue 653: Indefero crash on page /index.php/preferences/

Reported by William Martin, Mar 25, 2011

Exception making GET request to /index.php/preferences/
Method "get_idf_emailaddress_list" not available.

PHP: /var/www/pluf/src/Pluf/Model.php, line 386
URI: GET /index.php/preferences/

** Stacktrace **

* Pluf_Model->__call
        [No File, line 0] *
No src available.
* Pluf_User->get_idf_emailaddress_list
        [/var/www/indefero/src/IDF/EmailAddress.php, line 76] *
* Src *
71:                                    );
72:     }
73: 
74:     function get_email_addresses_for_user($user)
75:     {
>> 76:         $addr = $user->get_idf_emailaddress_list();
77:         $addr[] = (object)array("address" => 
$user->email, "id" => -1, "user" => 
$user);
78:         return $addr;
79:     }
80: 
81:     function get_user_for_email_address($email)

* IDF_EmailAddress->get_email_addresses_for_user
        [/var/www/indefero/src/IDF/Views/User.php, line 130] *
* Src *
125:             $data = $request->user->getData();
126:             unset($data['password']);
127:             $form = new IDF_Form_UserAccount(null, $params);
128:         }
129:         $keys = $request->user->get_idf_key_list();
>> 130:         $mailaddrs = 
Pluf::factory('IDF_EmailAddress')->get_email_addresses_for_user($r
equest->user);
131: 
132:         return 
Pluf_Shortcuts_RenderToResponse('idf/user/myaccount.html',
133:                                                
array('page_title' => __('Your Account'),
134:                                                      'api_key' 
=> $api_key,
135:                                                      'ext_pass' 
=> $ext_pass,

* IDF_Views_User->myAccount
        [/var/www/pluf/src/Pluf/Dispatcher.php, line 202] *
* Src *
197:                     return $res;
198:                 }
199:             } 
200:         }
201:         if (!isset($ctl['params'])) {
>> 202:             return $m->$ctl['method']($req, 
$match);
203:         } else {
204:             return $m->$ctl['method']($req, $match, 
$ctl['params']);
205:         }
206:     }
207: 

* Pluf_Dispatcher::send
        [/var/www/pluf/src/Pluf/Dispatcher.php, line 129] *
* Src *
124:             $i = 0;
125:             while ($i<$n) {
126:                 $ctl = $views[$i];
127:                 if (preg_match($ctl['regex'], $to_match, 
$match)) {
128:                     if (!isset($ctl['sub'])) {
>> 129:                         return self::send($req, $ctl, 
$match);
130:                     } else {
131:                         // Go in the subtree
132:                         $views = $ctl['sub'];
133:                         $i = 0;
134:                         $n = count($views);

* Pluf_Dispatcher::match
        [/var/www/pluf/src/Pluf/Dispatcher.php, line 56] *
* Src *
51:                         break;
52:                     }    
53:                 }
54:             }
55:             if ($skip === false) {   
>> 56:                 $response = self::match($req);
57:                 if (!empty($req->response_vary_on)) {
58:                     $response->headers['Vary'] = 
$req->response_vary_on;
59:                 }
60:                 $middleware = array_reverse($middleware);
61:                 foreach ($middleware as $mw) {

* Pluf_Dispatcher::dispatch
        [/var/www/indefero/www/index.php, line 28] *
* Src *
23: 
24: require dirname(__FILE__).'/../src/IDF/conf/path.php';
25: require 'Pluf.php';
26: Pluf::start(dirname(__FILE__).'/../src/IDF/conf/idf.php');
27: Pluf_Dispatcher::loadControllers(Pluf::f('idf_views'));
>> 28: Pluf_Dispatcher::dispatch(Pluf_HTTP_URL::getAction()); 
29: 
30: 
31: 





** Request **

* Request (raw) *

HEADERS
Host: 137.121.75.54
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; 
rv:1.9.1.16) Gecko/20101130 Firefox/3.5.16 ( .NET CLR 3.5.30729)
Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://137.121.75.54/index.php/dashboard/
Cookie: 
sessionid=YToyOntzOjE4OiJfUFhfUGx1Zl9Vc2VyX2F1dGgiO2k6MTY7czoxNjoiUGx
1Zl9TZXNzaW9uX2tleSI7czozMjoiODIzNDdiODllOGRjMmFiNTY4NTg1MjExZWNkMDI5
MzciO30%3D2b98e8120fcf0103f2f477d6e65b0b1e


* Request (parsed) *

$_GET
No data

$_POST
No data

$_COOKIE
Variable: sessionid
Value:    
YToyOntzOjE4OiJfUFhfUGx1Zl9Vc2VyX2F1dGgiO2k6MTY7czoxNjoiUGx1Zl9TZXNza
W9uX2tleSI7czozMjoiODIzNDdiODllOGRjMmFiNTY4NTg1MjExZWNkMDI5MzciO30=2b
98e8120fcf0103f2f477d6e65b0b1e

$_SERVER
Variable: HTTP_HOST
Value:    137.121.75.54
Variable: HTTP_USER_AGENT
Value:    Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.16) 
Gecko/20101130 Firefox/3.5.16 ( .NET CLR 3.5.30729)
Variable: HTTP_ACCEPT
Value:    
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Variable: HTTP_ACCEPT_LANGUAGE
Value:    fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Variable: HTTP_ACCEPT_ENCODING
Value:    gzip,deflate
Variable: HTTP_ACCEPT_CHARSET
Value:    ISO-8859-1,utf-8;q=0.7,*;q=0.7
Variable: HTTP_KEEP_ALIVE
Value:    300
Variable: HTTP_CONNECTION
Value:    keep-alive
Variable: HTTP_REFERER
Value:    http://137.121.75.54/index.php/dashboard/
Variable: HTTP_COOKIE
Value:    
sessionid=YToyOntzOjE4OiJfUFhfUGx1Zl9Vc2VyX2F1dGgiO2k6MTY7czoxNjoiUGx
1Zl9TZXNzaW9uX2tleSI7czozMjoiODIzNDdiODllOGRjMmFiNTY4NTg1MjExZWNkMDI5
MzciO30%3D2b98e8120fcf0103f2f477d6e65b0b1e
Variable: PATH
Value:    /usr/local/bin:/usr/bin:/bin
Variable: SERVER_SIGNATURE
Value:    <address>Apache/2.2.14 (Ubuntu) Server at 
137.121.75.54 Port 80</address>

Variable: SERVER_SOFTWARE
Value:    Apache/2.2.14 (Ubuntu)
Variable: SERVER_NAME
Value:    137.121.75.54
Variable: SERVER_ADDR
Value:    137.121.75.54
Variable: SERVER_PORT
Value:    80
Variable: REMOTE_ADDR
Value:    137.121.75.42
Variable: DOCUMENT_ROOT
Value:    /var/www
Variable: SERVER_ADMIN
Value:    webmaster@localhost
Variable: SCRIPT_FILENAME
Value:    /var/www/index.php
Variable: REMOTE_PORT
Value:    1545
Variable: GATEWAY_INTERFACE
Value:    CGI/1.1
Variable: SERVER_PROTOCOL
Value:    HTTP/1.1
Variable: REQUEST_METHOD
Value:    GET
Variable: QUERY_STRING
Value:    
Variable: REQUEST_URI
Value:    /index.php/preferences/
Variable: SCRIPT_NAME
Value:    /index.php
Variable: PATH_INFO
Value:    /preferences/
Variable: PATH_TRANSLATED
Value:    /var/www/preferences/
Variable: PHP_SELF
Value:    /index.php/preferences/
Variable: REQUEST_TIME
Value:    1301060708

$_ENV
No data





** Response **

* Headers *

X-Powered-By: PHP/5.3.2-1ubuntu4.7

Comment 1 by William Martin, Mar 25, 2011

Owner: ---

Comment 2 by Josh Henderson, Mar 25, 2011

I'm seeing something related when just accessing the page.

Exception making GET request to /preferences/
1146 - Table 'indeferodev.indefero_idf_emailaddresses' doesn't exist 
- SELECT indefero_idf_emailaddresses.`id` AS `id`, 
indefero_idf_emailaddresses.`user` AS `user`, 
indefero_idf_emailaddresses.`address` AS `address` FROM 
indefero_idf_emailaddresses WHERE (`user`=3)

Comment 3 by Patrick Georgi, Mar 25, 2011

Josh Henderson: Did you run the migrations after updating to 1.1?

Comment 4 by SqUe ⌚, Mar 26, 2011

I am having the same problem here. In my case I managed to reproduce 
the problem even on the same machine by simply doing the following:

# Before starting my database looks like:

mysql> show tables;
+-------------------------------------------+
| Tables_in_indefero                        |
+-------------------------------------------+
| indefero_groups                           |
| indefero_idf_commits                      |
| indefero_idf_conf                         |
| indefero_idf_emailaddresses               |< Table is here
| indefero_idf_gconf                        |
| indefero_idf_issue_idf_tag_assoc          |
| indefero_idf_issue_pluf_user_assoc        |
| indefero_idf_issuecomments                |
| indefero_idf_issuefiles                   |
| indefero_idf_issues                       |
| indefero_idf_keys                         |
| indefero_idf_projects                     |
| indefero_idf_queue                        |
| indefero_idf_review_comments              |
| indefero_idf_review_filecomments          |
| indefero_idf_review_idf_tag_assoc         |
| indefero_idf_review_patches               |
| indefero_idf_review_pluf_user_assoc       |
| indefero_idf_reviews                      |
| indefero_idf_scm_cache_git                |
| indefero_idf_search_occs                  |
| indefero_idf_tag_idf_upload_assoc         |
| indefero_idf_tag_idf_wikipage_assoc       |
| indefero_idf_tags                         |
| indefero_idf_timeline                     |
| indefero_idf_uploads                      |
| indefero_idf_wikipage_pluf_user_assoc     |
| indefero_idf_wikipages                    |
| indefero_idf_wikirevisions                |
| indefero_messages                         |
| indefero_permissions                      |
| indefero_pluf_group_pluf_permission_assoc |
| indefero_pluf_group_pluf_user_assoc       |
| indefero_pluf_permission_pluf_user_assoc  |
| indefero_pluf_queue                       |
| indefero_pluf_search_occs                 |
| indefero_pluf_search_stats                |
| indefero_pluf_search_words                |
| indefero_rowpermissions                   |
| indefero_schema_info                      |
| indefero_sessions                         |
| indefero_users                            |
+-------------------------------------------+
42 rows in set (0.00 sec)

mysql> select * from indefero_idf_emailaddresses;
Empty set (0.00 sec)

mysql> select * from indefero_schema_info;
+----+-------------+---------+
| id | application | version |
+----+-------------+---------+
|  1 | Pluf        |       5 |
|  2 | IDF         |      16 |< Schema v16 (IDF 1.1)
+----+-------------+---------+
2 rows in set (0.00 sec)

# Steps to reproduce
-------------------------------

1. Backup IDF and Pluf (migrate.php -r) -> backup-IDF.json and 
backup-Pluf.json
/opt/indefero/src$ php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=IDF -b ~ backup
/opt/indefero/src$ php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=Pluf -b ~ backup

2. Delete IDF and then Pluf (migrate.php -x)

/opt/indefero/src$ php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=IDF -x
Applications to uninstall: IDF
Please confirm that you want to uninstall by typing "yes": 
yes
/opt/indefero/src$ php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=Pluf -x
Applications to uninstall: Pluf
Please confirm that you want to uninstall by typing "yes": 
yes

3. Restore from the just backed up files
/opt/indefero/src$ php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=Pluf -r ~ backup
/opt/indefero/src$ php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=IDF -r ~ backup

4. Try to visit user preferences:
Exception making GET request to /preferences/
1146 - Table 'indefero.indefero_idf_emailaddresses' doesn't exist

# Database status after migrations

mysql> desc indefero_idf_emailaddresses;
ERROR 1146 (42S02): Table 'indefero.indefero_idf_emailaddresses' 
doesn't exist

mysql> select * from indefero_schema_info;
+----+-------------+---------+
| id | application | version |
+----+-------------+---------+
|  1 | Pluf        |       5 |
|  2 | IDF         |      16 |< Still says v16
+----+-------------+---------+
2 rows in set (0.00 sec)


Note: I retried the same test with a database that had entries 
inside the indefero_idf_emailaddresses table. The result was the 
same and info from this table was lost.

WORKAROUND
----------------
After migration go down to v15 and then back to v16 to rebuilt this 
table.
php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=IDF -v15
php /opt/pluf/src/migrate.php 
--conf=/opt/indefero/src/IDF/conf/idf.php --app=IDF -v16

Comment 5 by SqUe ⌚, Mar 26, 2011

After a chat at #indefero, _shteou_ pointed out that the model 
IDF_EmailAddress was missing from Backup.php. So we tried it out, by 
adding it and the whole process working smoothly now.

Attached is a patch fixing it. Credits @ shteou

Comment 6 by Patrick Georgi, Mar 26, 2011

The backup/restore bit was missing in the original description ;-) 

See http://projects.ceondo.com/p/indefero/issues/644/

Comment 7 by Thomas Keller, Mar 28, 2011

SqUe, thanks for tracking down this problem so fantastically and 
thanks also to Patrick for fixing this issue!
Status: Fixed

Created: 2 years 2 months ago by William Martin

Updated: 2 years 2 months ago

Status: Fixed

Followed by: 4 persons

Labels:
Type:Defect
Priority:Critical
Milestone:Release1.1.1