前提・実現したいこと
vmware上のcentos7のapacheサーバーの中に
owncloudというソフトをインストールしたのですがホスト側からブラウザで管理者画面を表示するときに
php
1Fatal error: Call to a member function getRequest() on a non-object in /var/www/html/owncloud/lib/private/response.php on line 77
と出て表示されませんでした。
エラー表示が示す記述は↓の通りです。
php
1ファイルの場所 2vim /var/www/html/owncloud/lib/private/response.php 3 4エラー表示に該当する行 5 77行目 $protocol = \OC::$server->getRequest()->getHttpProtocol();
#このコードを見たとき
1,このエラー表示がされたときどのようなことが不足していると考えられるのでしょうか?
2.またエラーを調べるときに見といた方がいいというものがあればご指導お願いします。
該当のソースコード
php
1<?php 2 * @author Andreas Fischer <bantu@owncloud.com> 3 * @author Bart Visscher <bartv@thisnet.nl> 4 * @author Jorn Friedrich Dreyer <jfd@butonic.de> 5 * @author Lukas Reschke <lukas@owncloud.com> 6 * @author Morris Jobke <hey@morrisjobke.de> 7 * @author Robin McCorkell <robin@mccorkell.me.uk> 8 * @author Thomas Muller <thomas.mueller@tmit.eu> 9 * @author Vincent Petry <pvince81@owncloud.com> 10 * 11 * @copyright Copyright (c) 2016, ownCloud, Inc. 12 * @license AGPL-3.0 13 * 14 * This code is free software: you can redistribute it and/or modify 15 * it under the terms of the GNU Affero General Public License, version 3, 16 * as published by the Free Software Foundation. 17 * 18 * This program is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU Affero General Public License for more details. 22 * 23 * along with this program. If not, see <http://www.gnu.org/licenses/> 24 * 25class OC_Response { 26 const STATUS_FOUND = 304; 27 const STATUS_NOT_MODIFIED = 304; 28 const STATUS_NOT_FOUND = 404; 29 const STATUS_INTERNAL_SERVER_ERROR = 500; 30 const STATUS_SERVICE_UNAVAILABLE = 503; 31 32 /** 33 * Enable response caching by sending correct HTTP headers 34 * @param integer $cache_time time to cache the response 35 * >0 cache time in seconds 36 * 0 and <0 enable default browser caching 37 * null cache indefinitly 38 */ 39 static public function enableCaching($cache_time = null) { 40 if (is_numeric($cache_time)) { 41 header('Pragma: public');// enable caching in IE 42 if ($cache_time > 0) { 43 self::setExpiresHeader('PT'.$cache_time.'S'); 44 } 45 else { 46 self::setExpiresHeader(0); 47 } 48 } 49 else { 50 header('Cache-Control: cache'); 51 header('Pragma: cache'); 52 } 53 54 /** 55 * disable browser caching 56 * @see enableCaching with cache_time = 0 57 */ 58 static public function disableCaching() { 59 self::enableCaching(0); 60 } 61 62 /** 63 * Set response status 64 * @param int $status a HTTP status code, see also the STATUS constants 65 */ 66 static public function setStatus($status) { 6777行目 → $protocol = \OC::$server->getRequest()->getHttpProtocol(); 68 switch($status) { 69 case self::STATUS_NOT_MODIFIED: 70 $status = $status . ' Not Modified'; 71 break; 72 case self::STATUS_TEMPORARY_REDIRECT: 73 if ($protocol == 'HTTP/1.1') { 74 break; 75 } else { 76 $status = self::STATUS_FOUND; 77 // fallthrough 78 } 79 case self::STATUS_FOUND; 80 $status = $status . ' Found'; 81 break; 82 case self::STATUS_NOT_FOUND; 83 $status = $status . ' Not Found'; 84 break; 85 case self::STATUS_INTERNAL_SERVER_ERROR; 86 $status = $status . ' Internal Server Error'; 87 break; 88 case self::STATUS_SERVICE_UNAVAILABLE; 89 $status = $status . ' Service Unavailable'; 90 break; 91 } 92 header($protocol.' '.$status); 93 } 94 95 /** 96 * Send redirect response 97 * @param string $location to redirect to 98 */ 99 static public function redirect($location) { 100 self::setStatus(self::STATUS_TEMPORARY_REDIRECT); 101 header('Location: '.$location); 102 } 103 104 /** 105 * Set reponse expire time 106 * @param string|DateTime $expires date-time when the response expires 107 * string for DateInterval from now 108 * DateTime object when to expire response 109 */ 110 static public function setExpiresHeader($expires) { 111 if (is_string($expires) && $expires[0] == 'P') { 112 $interval = $expires; 113 $expires = new DateTime('now'); 114 $expires->add(new DateInterval($interval)); 115 } 116 if ($expires instanceof DateTime) { 117 $expires->setTimezone(new DateTimeZone('GMT')); 118 $expires = $expires->format(DateTime::RFC2822); 119 } 120 header('Expires: '.$expires); 121 /** 122 * Checks and set ETag header, when the request matches sends a 123 * 'not modified' response 124 * @param string $etag token to use for modification check 125 */ 126 static public function setETagHeader($etag) { 127 } 128 $etag = '"'.$etag.'"'; 129 self::setStatus(self::STATUS_NOT_MODIFIED); 130 exit; 131 } 132 header('ETag: '.$etag); 133 } 134 135 /** 136 * Checks and set Last-Modified header, when the request matches sends a 137 * 'not modified' response 138 */ 139 static public function setLastModifiedHeader($lastModified) { 140 if (empty($lastModified)) { 141 if (is_int($lastModified)) { 142 } 143 self::setStatus(self::STATUS_NOT_MODIFIED); 144 145 /** 146 * Sets the content disposition header (with possible workarounds) 147 * @param string $filename file name 148 * @param string $type disposition type, either 'attachment' or 'inline' 149 */ 150 if (\OC::$server->getRequest()->isUserAgent( 151 } else { 152 } 153 } 154 155 /** 156 * Sets the content length header (with possible workarounds) 157 * @param string|int|float $length Length to be sent 158 */ 159 static public function setContentLengthHeader($length) { 160 if (PHP_INT_SIZE === 4) { 161 // bodies from being received incompletely. 162 return; 163 } 164 $lfh = new \OC\LargeFileHelper; 165 $length = $lfh->formatUnsignedInteger($length); 166 } 167 header('Content-Length: '.$length); 168 * @param string $filepath of file to send 169 */ 170 self::setETagHeader(md5_file($filepath)); 171 172 self::setContentLengthHeader(filesize($filepath)); 173 fpassthru($fp); 174 } 175 else { 176 self::setStatus(self::STATUS_NOT_FOUND); 177 } 178 } 179 180 /** 181 * components (e.g. SabreDAV) also benefit from this headers. 182 */ 183 . 'img-src * data: blob:; ' 184 . 'font-src \'self\' data:; ' 185 . 'media-src *; ' 186 . 'connect-src *'; 187 header('Content-Security-Policy:' . $policy); 188 189 // Send fallback headers for installations that don't have the possibility to send 190 // custom headers on the webserver side 191 if(getenv('modHeadersAvailable') !== 'true') { 192 header('X-XSS-Protection: 1; mode=block'); // Enforce browser based XSS filters 193 header('X-Content-Type-Options: nosniff'); // Disable sniffing the content type for IE 194 header('X-Frame-Options: Sameorigin'); // Disallow iFraming from other domains 195 header('X-Robots-Tag: none'); // https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag 196 header('X-Download-Options: noopen'); // https://msdn.microsoft.com/en-us/library/jj542450(v=vs.85).aspx 197 header('X-Permitted-Cross-Domain-Policies: none'); // https://www.adobe.com/devnet/adobe-media-server/articles/cross-domain-xml-for-streaming.html 198 } 199 } 200
試したこと
#1.用語の検索
クラスメソッドを実行して「Call to a member function」と表示されるときは、オブジェクト作成前に実行していたり、必要なオブジェクトインスタンスが生成されていないことが考えられます。
ということでしたがどの部分のインスタンスができていないのかよくわかりませんでした。
#2.php拡張モジュールの不足
以前真っ白になったときに拡張モジュールが不足していたため表示できなかったことがあったのですが、そのときのエラー表示がphp拡張モジュールを入れてくださいとはっきりと明記されていたので違うと考えています。
補足情報(FW/ツールのバージョンなど)
VMware(R) Workstation 12 Player 12.5.7 build-5813279
CentOS Linux release 7.5.1804 (Core)
Apache/2.4.6 (CentOS)
PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/31 08:24
2018/07/31 09:43