Index: trunk/phase3/includes/api/ApiQueryLogEvents.php |
— | — | @@ -40,8 +40,6 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | public function execute() { |
44 | | - throw new MWException( "This query breaks database servers. It will be restored to service when it works reliably." ); |
45 | | - |
46 | 44 | $params = $this->extractRequestParams(); |
47 | 45 | $db = $this->getDB(); |
48 | 46 | |
— | — | @@ -67,7 +65,7 @@ |
68 | 66 | array( 'log_namespace=page_namespace', |
69 | 67 | 'log_title=page_title')))); |
70 | 68 | $this->addWhere('user_id=log_user'); |
71 | | - $this->addOption('USE INDEX', array('logging' => 'times')); |
| 69 | + $this->addOption('USE INDEX', array('logging' => 'times')); // default, may change |
72 | 70 | |
73 | 71 | $this->addFields(array ( |
74 | 72 | 'log_type', |
— | — | @@ -75,8 +73,7 @@ |
76 | 74 | 'log_timestamp', |
77 | 75 | )); |
78 | 76 | |
79 | | - // FIXME: Fake out log_id for now until the column is live on Wikimedia |
80 | | - // $this->addFieldsIf('log_id', $this->fld_ids); |
| 77 | + $this->addFieldsIf('log_id', $this->fld_ids); |
81 | 78 | $this->addFieldsIf('page_id', $this->fld_ids); |
82 | 79 | $this->addFieldsIf('log_user', $this->fld_user); |
83 | 80 | $this->addFieldsIf('user_name', $this->fld_user); |
— | — | @@ -86,7 +83,12 @@ |
87 | 84 | $this->addFieldsIf('log_params', $this->fld_details); |
88 | 85 | |
89 | 86 | $this->addWhereFld('log_deleted', 0); |
90 | | - $this->addWhereFld('log_type', $params['type']); |
| 87 | + |
| 88 | + if( !is_null($params['type']) ) { |
| 89 | + $this->addWhereFld('log_type', $params['type']); |
| 90 | + $this->addOption('USE INDEX', array('logging' => array('type_time'))); |
| 91 | + } |
| 92 | + |
91 | 93 | $this->addWhereRange('log_timestamp', $params['dir'], $params['start'], $params['end']); |
92 | 94 | |
93 | 95 | $limit = $params['limit']; |
— | — | @@ -100,6 +102,7 @@ |
101 | 103 | if (!$userid) |
102 | 104 | $this->dieUsage("User name $user not found", 'param_user'); |
103 | 105 | $this->addWhereFld('log_user', $userid); |
| 106 | + $this->addOption('USE INDEX', array('logging' => array('user_time','page_time'))); |
104 | 107 | } |
105 | 108 | |
106 | 109 | $title = $params['title']; |
— | — | @@ -109,6 +112,7 @@ |
110 | 113 | $this->dieUsage("Bad title value '$title'", 'param_title'); |
111 | 114 | $this->addWhereFld('log_namespace', $titleObj->getNamespace()); |
112 | 115 | $this->addWhereFld('log_title', $titleObj->getDBkey()); |
| 116 | + $this->addOption('USE INDEX', array('logging' => array('user_time','page_time'))); |
113 | 117 | } |
114 | 118 | |
115 | 119 | $data = array (); |